You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2015/07/08 20:35:22 UTC

logging-log4j2 git commit: Rewrite Bzip2CompressAction as CommonsCompressAction, the callers only use bzip2 ATM.

Repository: logging-log4j2
Updated Branches:
  refs/heads/master 19fc1c913 -> 62bcbcced


Rewrite Bzip2CompressAction as CommonsCompressAction, the callers only
use bzip2 ATM. 

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/62bcbcce
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/62bcbcce
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/62bcbcce

Branch: refs/heads/master
Commit: 62bcbccedc6890c69896be3b8ed3f7f31e36d4ec
Parents: 19fc1c9
Author: ggregory <gg...@apache.org>
Authored: Wed Jul 8 11:35:17 2015 -0700
Committer: ggregory <gg...@apache.org>
Committed: Wed Jul 8 11:35:17 2015 -0700

----------------------------------------------------------------------
 .../rolling/DefaultRolloverStrategy.java        |   4 +-
 .../rolling/action/Bzip2CompressAction.java     | 127 ----------
 .../rolling/action/CommonsCompressAction.java   | 130 ++++++++++
 .../rolling/action/Bzip2CompressActionTest.java | 240 +++++++++----------
 4 files changed, 252 insertions(+), 249 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/62bcbcce/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
index 500c302..d538d90 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java
@@ -24,7 +24,7 @@ import java.util.zip.Deflater;
 
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.appender.rolling.action.Action;
-import org.apache.logging.log4j.core.appender.rolling.action.Bzip2CompressAction;
+import org.apache.logging.log4j.core.appender.rolling.action.CommonsCompressAction;
 import org.apache.logging.log4j.core.appender.rolling.action.FileRenameAction;
 import org.apache.logging.log4j.core.appender.rolling.action.GzCompressAction;
 import org.apache.logging.log4j.core.appender.rolling.action.ZipCompressAction;
@@ -96,7 +96,7 @@ public class DefaultRolloverStrategy implements RolloverStrategy {
         BZIP2(".bz2") {
             Action createCompressAction(String renameTo, String compressedName, boolean deleteSource,
                     int compressionLevel) {
-                return new Bzip2CompressAction(new File(baseName(renameTo)), new File(compressedName), deleteSource);
+                return new CommonsCompressAction("bzip2", new File(baseName(renameTo)), new File(compressedName), deleteSource);
             }
         };
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/62bcbcce/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/Bzip2CompressAction.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/Bzip2CompressAction.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/Bzip2CompressAction.java
deleted file mode 100644
index e3f2b27..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/Bzip2CompressAction.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.core.appender.rolling.action;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Objects;
-
-import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream;
-
-/**
- * Compresses a file using bzip2 compression.
- */
-public final class Bzip2CompressAction extends AbstractAction {
-
-    private static final int BUF_SIZE = 8102;
-
-    /**
-     * Source file.
-     */
-    private final File source;
-
-    /**
-     * Destination file.
-     */
-    private final File destination;
-
-    /**
-     * If true, attempt to delete file on completion.
-     */
-    private final boolean deleteSource;
-
-    /**
-     * Create new instance of Bzip2CompressAction.
-     *
-     * @param source file to compress, may not be null.
-     * @param destination compressed file, may not be null.
-     * @param deleteSource if true, attempt to delete file on completion. Failure to delete does not cause an exception
-     *            to be thrown or affect return value.
-     */
-    public Bzip2CompressAction(final File source, final File destination, final boolean deleteSource) {
-        Objects.requireNonNull(source, "source");
-        Objects.requireNonNull(destination, "destination");
-
-        this.source = source;
-        this.destination = destination;
-        this.deleteSource = deleteSource;
-    }
-
-    /**
-     * Compress.
-     *
-     * @return true if successfully compressed.
-     * @throws IOException on IO exception.
-     */
-    @Override
-    public boolean execute() throws IOException {
-        return execute(source, destination, deleteSource);
-    }
-
-    /**
-     * Compress a file.
-     *
-     * @param source file to compress, may not be null.
-     * @param destination compressed file, may not be null.
-     * @param deleteSource if true, attempt to delete file on completion. Failure to delete does not cause an exception
-     *            to be thrown or affect return value.
-     * @return true if source file compressed.
-     * @throws IOException on IO exception.
-     */
-    public static boolean execute(final File source, final File destination, final boolean deleteSource)
-            throws IOException {
-        if (source.exists()) {
-            try (final FileInputStream fis = new FileInputStream(source);
-                    final BufferedOutputStream os = new BufferedOutputStream(new BZip2CompressorOutputStream(
-                            new FileOutputStream(destination)))) {
-                final byte[] inbuf = new byte[BUF_SIZE];
-                int n;
-
-                while ((n = fis.read(inbuf)) != -1) {
-                    os.write(inbuf, 0, n);
-                }
-            }
-
-            if (deleteSource && !source.delete()) {
-                LOGGER.warn("Unable to delete " + source.toString() + '.');
-            }
-
-            return true;
-        }
-
-        return false;
-    }
-
-    /**
-     * Capture exception.
-     *
-     * @param ex exception.
-     */
-    @Override
-    protected void reportException(final Exception ex) {
-        LOGGER.warn("Exception during bzip2 compression of '" + source.toString() + "'.", ex);
-    }
-
-    @Override
-    public String toString() {
-        return Bzip2CompressAction.class.getSimpleName() + '[' + source + " to " + destination //
-                + ", deleteSource=" + deleteSource + ']';
-    }
-}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/62bcbcce/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/CommonsCompressAction.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/CommonsCompressAction.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/CommonsCompressAction.java
new file mode 100644
index 0000000..7aa75fe
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/CommonsCompressAction.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.appender.rolling.action;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Objects;
+
+import org.apache.commons.compress.compressors.CompressorException;
+import org.apache.commons.compress.compressors.CompressorStreamFactory;
+import org.apache.commons.compress.utils.IOUtils;
+
+/**
+ * Compresses a file using bzip2 compression.
+ */
+public final class CommonsCompressAction extends AbstractAction {
+
+    private static final int BUF_SIZE = 8102;
+
+    /**
+     * Compressor name.
+     */
+    private final String name;
+
+    /**
+     * Source file.
+     */
+    private final File source;
+
+    /**
+     * Destination file.
+     */
+    private final File destination;
+
+    /**
+     * If true, attempt to delete file on completion.
+     */
+    private final boolean deleteSource;
+
+    /**
+     * Creates new instance of Bzip2CompressAction.
+     * @param name the compressor name, i.e. "gz", "bzip2", "xz", "pack200", or "deflate".
+     * @param source file to compress, may not be null.
+     * @param destination compressed file, may not be null.
+     * @param deleteSource if true, attempt to delete file on completion. Failure to delete does not cause an exception
+     *            to be thrown or affect return value.
+     */
+    public CommonsCompressAction(String name, final File source, final File destination, final boolean deleteSource) {
+        Objects.requireNonNull(source, "source");
+        Objects.requireNonNull(destination, "destination");
+        this.name = name;
+        this.source = source;
+        this.destination = destination;
+        this.deleteSource = deleteSource;
+    }
+
+    /**
+     * Compresses.
+     *
+     * @return true if successfully compressed.
+     * @throws IOException on IO exception.
+     */
+    @Override
+    public boolean execute() throws IOException {
+        return execute(name, source, destination, deleteSource);
+    }
+
+    /**
+     * Compresses a file.
+     * @param name the compressor name, i.e. "gz", "bzip2", "xz", "pack200", or "deflate".
+     * @param source file to compress, may not be null.
+     * @param destination compressed file, may not be null.
+     * @param deleteSource if true, attempt to delete file on completion. Failure to delete does not cause an exception
+     *            to be thrown or affect return value.
+     *
+     * @return true if source file compressed.
+     * @throws IOException on IO exception.
+     */
+    public static boolean execute(String name, final File source, final File destination, final boolean deleteSource)
+            throws IOException {
+        if (!source.exists()) {
+            return false;
+        }
+        try (final FileInputStream input = new FileInputStream(source);
+                final BufferedOutputStream output = new BufferedOutputStream(new CompressorStreamFactory()
+                        .createCompressorOutputStream(name, new FileOutputStream(destination)))) {
+            IOUtils.copy(input, output, BUF_SIZE);
+        } catch (CompressorException e) {
+            throw new IOException(e);
+        }
+
+        if (deleteSource && !source.delete()) {
+            LOGGER.warn("Unable to delete " + source.toString() + '.');
+        }
+        return true;
+    }
+
+    /**
+     * Reports exception.
+     *
+     * @param ex exception.
+     */
+    @Override
+    protected void reportException(final Exception ex) {
+        LOGGER.warn("Exception during " + name + " compression of '" + source.toString() + "'.", ex);
+    }
+
+    @Override
+    public String toString() {
+        return CommonsCompressAction.class.getSimpleName() + '[' + source + " to " + destination //
+                + ", deleteSource=" + deleteSource + ']';
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/62bcbcce/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/Bzip2CompressActionTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/Bzip2CompressActionTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/Bzip2CompressActionTest.java
index df53c80..90ac04d 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/Bzip2CompressActionTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/action/Bzip2CompressActionTest.java
@@ -1,120 +1,120 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.logging.log4j.core.appender.rolling.action;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-
-import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests Bzip2CompressAction.
- */
-public class Bzip2CompressActionTest {
-
-    @Test(expected = NullPointerException.class)
-    public void testConstructorDisallowsNullSource() {
-        new Bzip2CompressAction(null, new File("any"), true);
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void testConstructorDisallowsNullDestination() {
-        new Bzip2CompressAction(new File("any"), null, true);
-    }
-
-    @Test
-    public void testExecuteReturnsFalseIfSourceDoesNotExist() throws IOException {
-        File source = new File("any");
-        while (source.exists()) {
-            source = new File(source.getName() + Math.random());
-        }
-        boolean actual = Bzip2CompressAction.execute(source, new File("any2"), true);
-        assertEquals("Cannot compress non-existing file", false, actual);
-    }
-
-    @Test
-    public void testExecuteCompressesSourceFileToDestinationFile() throws IOException {
-        final String LINE1 = "Here is line 1. Random text: ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n";
-        final String LINE2 = "Here is line 2. Random text: ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n";
-        final String LINE3 = "Here is line 3. Random text: ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n";
-        final File source = new File("target/compressme");
-        try (FileWriter fw = new FileWriter(source, false)) {
-            fw.write(LINE1);
-            fw.write(LINE2);
-            fw.write(LINE3);
-            fw.flush();
-        }
-        final File destination = new File("target/compressme.bz2");
-        destination.delete(); // just in case
-        assertFalse("Destination should not exist yet", destination.exists());
-
-        final boolean actual = Bzip2CompressAction.execute(source, destination, true);
-        assertEquals("Bzip2CompressAction should have succeeded", true, actual);
-        assertTrue("Destination should exist after Bzip2CompressAction", destination.exists());
-        assertFalse("Source should have been deleted", source.exists());
-
-        final byte[] bz2 = new byte[] { (byte) 0x42, (byte) 0x5A, (byte) 0x68, (byte) 0x39, (byte) 0x31, (byte) 0x41,
-                (byte) 0x59, (byte) 0x26, (byte) 0x53, (byte) 0x59, (byte) 0x9C, (byte) 0xE1, (byte) 0xE8, (byte) 0x2D,
-                (byte) 0x00, (byte) 0x00, (byte) 0x1C, (byte) 0xDF, (byte) 0x80, (byte) 0x00, (byte) 0x12, (byte) 0x40,
-                (byte) 0x01, (byte) 0x38, (byte) 0x10, (byte) 0x3F, (byte) 0xFF, (byte) 0xFF, (byte) 0xF0, (byte) 0x26,
-                (byte) 0x27, (byte) 0x9C, (byte) 0x40, (byte) 0x20, (byte) 0x00, (byte) 0x70, (byte) 0x63, (byte) 0x4D,
-                (byte) 0x06, (byte) 0x80, (byte) 0x19, (byte) 0x34, (byte) 0x06, (byte) 0x46, (byte) 0x9A, (byte) 0x18,
-                (byte) 0x9A, (byte) 0x30, (byte) 0xCF, (byte) 0xFD, (byte) 0x55, (byte) 0x4D, (byte) 0x0D, (byte) 0x06,
-                (byte) 0x9A, (byte) 0x0C, (byte) 0x40, (byte) 0x1A, (byte) 0x1A, (byte) 0x34, (byte) 0x34, (byte) 0xCD,
-                (byte) 0x46, (byte) 0x05, (byte) 0x6B, (byte) 0x19, (byte) 0x92, (byte) 0x23, (byte) 0x5E, (byte) 0xB5,
-                (byte) 0x2E, (byte) 0x79, (byte) 0x65, (byte) 0x41, (byte) 0x81, (byte) 0x33, (byte) 0x4B, (byte) 0x53,
-                (byte) 0x5B, (byte) 0x62, (byte) 0x75, (byte) 0x0A, (byte) 0x14, (byte) 0xB6, (byte) 0xB7, (byte) 0x37,
-                (byte) 0xB8, (byte) 0x38, (byte) 0xB9, (byte) 0x39, (byte) 0xBA, (byte) 0x2A, (byte) 0x4E, (byte) 0xEA,
-                (byte) 0xEC, (byte) 0xEE, (byte) 0xAD, (byte) 0xE1, (byte) 0xE5, (byte) 0x63, (byte) 0xD3, (byte) 0x22,
-                (byte) 0xE8, (byte) 0x90, (byte) 0x52, (byte) 0xA9, (byte) 0x7A, (byte) 0x68, (byte) 0x90, (byte) 0x5C,
-                (byte) 0x82, (byte) 0x0B, (byte) 0x51, (byte) 0xBF, (byte) 0x24, (byte) 0x61, (byte) 0x7F, (byte) 0x17,
-                (byte) 0x72, (byte) 0x45, (byte) 0x38, (byte) 0x50, (byte) 0x90, (byte) 0x9C, (byte) 0xE1, (byte) 0xE8,
-                (byte) 0x2D };
-        assertEquals(bz2.length, destination.length());
-
-        // check the compressed contents
-        try (FileInputStream fis = new FileInputStream(destination)) {
-            final byte[] actualBz2 = new byte[bz2.length];
-            int n = 0;
-            int offset = 0;
-            do {
-                n = fis.read(actualBz2, offset, actualBz2.length - offset);
-                offset += n;
-            } while (offset < actualBz2.length);
-            assertArrayEquals("Compressed data corrupt", bz2, actualBz2);
-        }
-        destination.delete();
-
-        // uncompress
-        try (BZip2CompressorInputStream bzin = new BZip2CompressorInputStream(new ByteArrayInputStream(bz2))) {
-            final StringBuilder sb = new StringBuilder();
-            final byte[] buf = new byte[1024];
-            int n = 0;
-            while ((n = bzin.read(buf, 0, buf.length)) > -1) {
-                sb.append(new String(buf, 0, n));
-            }
-            assertEquals(LINE1 + LINE2 + LINE3, sb.toString());
-        }
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.logging.log4j.core.appender.rolling.action;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Tests Bzip2CompressAction.
+ */
+public class Bzip2CompressActionTest {
+
+    @Test(expected = NullPointerException.class)
+    public void testConstructorDisallowsNullSource() {
+        new CommonsCompressAction("bzip2", null, new File("any"), true);
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void testConstructorDisallowsNullDestination() {
+        new CommonsCompressAction("bzip2", new File("any"), null, true);
+    }
+
+    @Test
+    public void testExecuteReturnsFalseIfSourceDoesNotExist() throws IOException {
+        File source = new File("any");
+        while (source.exists()) {
+            source = new File(source.getName() + Math.random());
+        }
+        boolean actual = CommonsCompressAction.execute("bzip2", source, new File("any2"), true);
+        assertEquals("Cannot compress non-existing file", false, actual);
+    }
+
+    @Test
+    public void testExecuteCompressesSourceFileToDestinationFile() throws IOException {
+        final String LINE1 = "Here is line 1. Random text: ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n";
+        final String LINE2 = "Here is line 2. Random text: ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n";
+        final String LINE3 = "Here is line 3. Random text: ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n";
+        final File source = new File("target/compressme");
+        try (FileWriter fw = new FileWriter(source, false)) {
+            fw.write(LINE1);
+            fw.write(LINE2);
+            fw.write(LINE3);
+            fw.flush();
+        }
+        final File destination = new File("target/compressme.bz2");
+        destination.delete(); // just in case
+        assertFalse("Destination should not exist yet", destination.exists());
+
+        final boolean actual = CommonsCompressAction.execute("bzip2", source, destination, true);
+        assertEquals("Bzip2CompressAction should have succeeded", true, actual);
+        assertTrue("Destination should exist after Bzip2CompressAction", destination.exists());
+        assertFalse("Source should have been deleted", source.exists());
+
+        final byte[] bz2 = new byte[] { (byte) 0x42, (byte) 0x5A, (byte) 0x68, (byte) 0x39, (byte) 0x31, (byte) 0x41,
+                (byte) 0x59, (byte) 0x26, (byte) 0x53, (byte) 0x59, (byte) 0x9C, (byte) 0xE1, (byte) 0xE8, (byte) 0x2D,
+                (byte) 0x00, (byte) 0x00, (byte) 0x1C, (byte) 0xDF, (byte) 0x80, (byte) 0x00, (byte) 0x12, (byte) 0x40,
+                (byte) 0x01, (byte) 0x38, (byte) 0x10, (byte) 0x3F, (byte) 0xFF, (byte) 0xFF, (byte) 0xF0, (byte) 0x26,
+                (byte) 0x27, (byte) 0x9C, (byte) 0x40, (byte) 0x20, (byte) 0x00, (byte) 0x70, (byte) 0x63, (byte) 0x4D,
+                (byte) 0x06, (byte) 0x80, (byte) 0x19, (byte) 0x34, (byte) 0x06, (byte) 0x46, (byte) 0x9A, (byte) 0x18,
+                (byte) 0x9A, (byte) 0x30, (byte) 0xCF, (byte) 0xFD, (byte) 0x55, (byte) 0x4D, (byte) 0x0D, (byte) 0x06,
+                (byte) 0x9A, (byte) 0x0C, (byte) 0x40, (byte) 0x1A, (byte) 0x1A, (byte) 0x34, (byte) 0x34, (byte) 0xCD,
+                (byte) 0x46, (byte) 0x05, (byte) 0x6B, (byte) 0x19, (byte) 0x92, (byte) 0x23, (byte) 0x5E, (byte) 0xB5,
+                (byte) 0x2E, (byte) 0x79, (byte) 0x65, (byte) 0x41, (byte) 0x81, (byte) 0x33, (byte) 0x4B, (byte) 0x53,
+                (byte) 0x5B, (byte) 0x62, (byte) 0x75, (byte) 0x0A, (byte) 0x14, (byte) 0xB6, (byte) 0xB7, (byte) 0x37,
+                (byte) 0xB8, (byte) 0x38, (byte) 0xB9, (byte) 0x39, (byte) 0xBA, (byte) 0x2A, (byte) 0x4E, (byte) 0xEA,
+                (byte) 0xEC, (byte) 0xEE, (byte) 0xAD, (byte) 0xE1, (byte) 0xE5, (byte) 0x63, (byte) 0xD3, (byte) 0x22,
+                (byte) 0xE8, (byte) 0x90, (byte) 0x52, (byte) 0xA9, (byte) 0x7A, (byte) 0x68, (byte) 0x90, (byte) 0x5C,
+                (byte) 0x82, (byte) 0x0B, (byte) 0x51, (byte) 0xBF, (byte) 0x24, (byte) 0x61, (byte) 0x7F, (byte) 0x17,
+                (byte) 0x72, (byte) 0x45, (byte) 0x38, (byte) 0x50, (byte) 0x90, (byte) 0x9C, (byte) 0xE1, (byte) 0xE8,
+                (byte) 0x2D };
+        assertEquals(bz2.length, destination.length());
+
+        // check the compressed contents
+        try (FileInputStream fis = new FileInputStream(destination)) {
+            final byte[] actualBz2 = new byte[bz2.length];
+            int n = 0;
+            int offset = 0;
+            do {
+                n = fis.read(actualBz2, offset, actualBz2.length - offset);
+                offset += n;
+            } while (offset < actualBz2.length);
+            assertArrayEquals("Compressed data corrupt", bz2, actualBz2);
+        }
+        destination.delete();
+
+        // uncompress
+        try (BZip2CompressorInputStream bzin = new BZip2CompressorInputStream(new ByteArrayInputStream(bz2))) {
+            final StringBuilder sb = new StringBuilder();
+            final byte[] buf = new byte[1024];
+            int n = 0;
+            while ((n = bzin.read(buf, 0, buf.length)) > -1) {
+                sb.append(new String(buf, 0, n));
+            }
+            assertEquals(LINE1 + LINE2 + LINE3, sb.toString());
+        }
+    }
+}