Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsliebig2007-11-06 14:40:03 +0000
committersliebig2007-11-06 14:40:03 +0000
commite8fda18fa74ad3f4a5d042aa1f900069b8aed69e (patch)
tree4017bdde96943125fe7347a38da462813b1d0618 /bundles/ie.wombat.jbdiff.test
parent2badfd3121cad9b9859a3287cc08b9b4cd07ba93 (diff)
downloadrt.equinox.p2-e8fda18fa74ad3f4a5d042aa1f900069b8aed69e.tar.gz
rt.equinox.p2-e8fda18fa74ad3f4a5d042aa1f900069b8aed69e.tar.xz
rt.equinox.p2-e8fda18fa74ad3f4a5d042aa1f900069b8aed69e.zip
included Bzip2
Diffstat (limited to 'bundles/ie.wombat.jbdiff.test')
-rw-r--r--bundles/ie.wombat.jbdiff.test/src/org/apache/tools/bzip2/test/Activator.java34
-rw-r--r--bundles/ie.wombat.jbdiff.test/src/org/apache/tools/bzip2/test/CBZip2OutputStreamTest.java180
2 files changed, 214 insertions, 0 deletions
diff --git a/bundles/ie.wombat.jbdiff.test/src/org/apache/tools/bzip2/test/Activator.java b/bundles/ie.wombat.jbdiff.test/src/org/apache/tools/bzip2/test/Activator.java
new file mode 100644
index 000000000..b393a9691
--- /dev/null
+++ b/bundles/ie.wombat.jbdiff.test/src/org/apache/tools/bzip2/test/Activator.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2007 compeople AG 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:
+ * compeople AG (Stefan Liebig) - initial API and implementation
+ *******************************************************************************/
+package org.apache.tools.bzip2.test;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ }
+
+}
diff --git a/bundles/ie.wombat.jbdiff.test/src/org/apache/tools/bzip2/test/CBZip2OutputStreamTest.java b/bundles/ie.wombat.jbdiff.test/src/org/apache/tools/bzip2/test/CBZip2OutputStreamTest.java
new file mode 100644
index 000000000..7cfc8bebb
--- /dev/null
+++ b/bundles/ie.wombat.jbdiff.test/src/org/apache/tools/bzip2/test/CBZip2OutputStreamTest.java
@@ -0,0 +1,180 @@
+/*******************************************************************************
+ * Copyright (c) 2007 compeople AG 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:
+ * compeople AG (Stefan Liebig) - initial API and implementation
+ *******************************************************************************/
+package org.apache.tools.bzip2.test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.tools.bzip2.CBZip2InputStream;
+import org.apache.tools.bzip2.CBZip2OutputStream;
+
+public class CBZip2OutputStreamTest extends TestCase {
+
+ /**
+ * @throws IOException
+ */
+ public void testEmtpyOutputShouldNotFail() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ CBZip2OutputStream outputStream = new CBZip2OutputStream(
+ byteArrayOutputStream);
+ outputStream.close();
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
+ byteArrayOutputStream.toByteArray());
+
+ CBZip2InputStream inputStream = new CBZip2InputStream(
+ byteArrayInputStream);
+ assertEquals(-1, inputStream.read());
+ }
+
+ /**
+ * @throws IOException
+ */
+ public void testOneByteOutputAndOneByteIn() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ CBZip2OutputStream outputStream = new CBZip2OutputStream(
+ byteArrayOutputStream);
+ outputStream.write(42);
+ outputStream.close();
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
+ byteArrayOutputStream.toByteArray());
+
+ CBZip2InputStream inputStream = new CBZip2InputStream(
+ byteArrayInputStream);
+ assertEquals(42, inputStream.read());
+ assertEquals(-1, inputStream.read());
+ }
+
+ /**
+ * @throws IOException
+ */
+ public void testWriteFinishAndClose() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ CBZip2OutputStream outputStream = new CBZip2OutputStream(
+ byteArrayOutputStream);
+ outputStream.flush();
+ int len = byteArrayOutputStream.toByteArray().length;
+
+ outputStream.write(42);
+ outputStream.finish();
+
+ int lenAfterWrite = byteArrayOutputStream.toByteArray().length;
+ assertTrue(len != lenAfterWrite);
+
+ outputStream.close();
+ int lenAfterClose = byteArrayOutputStream.toByteArray().length;
+ assertTrue(lenAfterWrite == lenAfterClose);
+
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
+ byteArrayOutputStream.toByteArray());
+
+ CBZip2InputStream inputStream = new CBZip2InputStream(
+ byteArrayInputStream);
+ assertEquals(42, inputStream.read());
+ assertEquals(-1, inputStream.read());
+ }
+
+ /**
+ * @throws IOException
+ */
+ public void testWriteFinishFinishAndClose() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ CBZip2OutputStream outputStream = new CBZip2OutputStream(
+ byteArrayOutputStream);
+ outputStream.flush();
+ int len = byteArrayOutputStream.toByteArray().length;
+
+ outputStream.write(42);
+ outputStream.finish();
+ outputStream.finish();
+
+ int lenAfterWrite = byteArrayOutputStream.toByteArray().length;
+ assertTrue(len != lenAfterWrite);
+
+ outputStream.close();
+ int lenAfterClose = byteArrayOutputStream.toByteArray().length;
+ assertTrue(lenAfterWrite == lenAfterClose);
+
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
+ byteArrayOutputStream.toByteArray());
+
+ CBZip2InputStream inputStream = new CBZip2InputStream(
+ byteArrayInputStream);
+ assertEquals(42, inputStream.read());
+ assertEquals(-1, inputStream.read());
+ }
+
+ /**
+ * @throws IOException
+ */
+ public void testWriteFinishAndCloseClose() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ CBZip2OutputStream outputStream = new CBZip2OutputStream(
+ byteArrayOutputStream);
+ outputStream.flush();
+ int len = byteArrayOutputStream.toByteArray().length;
+
+ outputStream.write(42);
+ outputStream.finish();
+
+ int lenAfterWrite = byteArrayOutputStream.toByteArray().length;
+ assertTrue(len != lenAfterWrite);
+
+ outputStream.close();
+ int lenAfterClose1 = byteArrayOutputStream.toByteArray().length;
+ assertTrue(lenAfterWrite == lenAfterClose1);
+ outputStream.close();
+ int lenAfterClose2 = byteArrayOutputStream.toByteArray().length;
+ assertTrue(lenAfterWrite == lenAfterClose2);
+
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
+ byteArrayOutputStream.toByteArray());
+
+ CBZip2InputStream inputStream = new CBZip2InputStream(
+ byteArrayInputStream);
+ assertEquals(42, inputStream.read());
+ assertEquals(-1, inputStream.read());
+ }
+
+ /**
+ * @throws IOException
+ */
+ public void testWriteFinishWriteClose() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ CBZip2OutputStream outputStream = new CBZip2OutputStream(
+ byteArrayOutputStream);
+ outputStream.flush();
+ int len = byteArrayOutputStream.toByteArray().length;
+
+ outputStream.write(42);
+ outputStream.finish();
+ outputStream.write(21);
+ outputStream.finish();
+
+ int lenAfterWrite = byteArrayOutputStream.toByteArray().length;
+ assertTrue(len != lenAfterWrite);
+
+ outputStream.close();
+ int lenAfterClose = byteArrayOutputStream.toByteArray().length;
+ assertTrue(lenAfterWrite == lenAfterClose);
+
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
+ byteArrayOutputStream.toByteArray());
+
+ CBZip2InputStream inputStream = new CBZip2InputStream(
+ byteArrayInputStream);
+ assertEquals(42, inputStream.read());
+ assertEquals(-1, inputStream.read());
+ }
+
+}

Back to the top