Repository: commons-compress
Updated Branches:
  refs/heads/master 7254daa3f -> 0960a387c


add-some-Unit-Tests Added additional Unit Tests.


Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/3c2419db
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/3c2419db
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/3c2419db

Branch: refs/heads/master
Commit: 3c2419db66d156dae631715d5d42ef90e36ad7da
Parents: cf9f45b
Author: Michael Hausegger <michael.hauseg...@tugraz.at>
Authored: Fri Jun 16 22:16:06 2017 +0200
Committer: Stefan Bodewig <bode...@apache.org>
Committed: Sat Jun 17 10:20:10 2017 +0200

----------------------------------------------------------------------
 .../compress/archivers/cpio/CpioUtilTest.java   | 31 +++++++++-
 .../commons/compress/changes/ChangeTest.java    | 64 ++++++++++++++++++++
 .../xz/XZCompressorOutputStreamTest.java        | 51 ++++++++++++++++
 .../z/ZCompressorInputStreamTest.java           | 54 +++++++++++++++++
 4 files changed, 198 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3c2419db/src/test/java/org/apache/commons/compress/archivers/cpio/CpioUtilTest.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/commons/compress/archivers/cpio/CpioUtilTest.java 
b/src/test/java/org/apache/commons/compress/archivers/cpio/CpioUtilTest.java
index 329d481..5b1edb5 100644
--- a/src/test/java/org/apache/commons/compress/archivers/cpio/CpioUtilTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/cpio/CpioUtilTest.java
@@ -18,11 +18,11 @@
  */
 package org.apache.commons.compress.archivers.cpio;
 
+import org.junit.Test;
+
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 
-import org.junit.Test;
-
 public class CpioUtilTest {
 
     @Test
@@ -53,4 +53,31 @@ public class CpioUtilTest {
                                              true));
     }
 
+
+    @Test(expected = UnsupportedOperationException.class)
+    public void 
testLong2byteArrayWithZeroThrowsUnsupportedOperationException() {
+
+        CpioUtil.long2byteArray(0L, 0, false);
+
+    }
+
+
+    @Test(expected = UnsupportedOperationException.class)
+    public void 
testLong2byteArrayWithPositiveThrowsUnsupportedOperationException() {
+
+        CpioUtil.long2byteArray(0L, 1021, false);
+
+    }
+
+
+    @Test(expected = UnsupportedOperationException.class)
+    public void testByteArray2longThrowsUnsupportedOperationException() {
+
+        byte[] byteArray = new byte[1];
+
+        CpioUtil.byteArray2long(byteArray, true);
+
+    }
+
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3c2419db/src/test/java/org/apache/commons/compress/changes/ChangeTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/changes/ChangeTest.java 
b/src/test/java/org/apache/commons/compress/changes/ChangeTest.java
new file mode 100644
index 0000000..907041c
--- /dev/null
+++ b/src/test/java/org/apache/commons/compress/changes/ChangeTest.java
@@ -0,0 +1,64 @@
+/*
+ * 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.commons.compress.changes;
+
+import org.apache.commons.compress.archivers.memory.MemoryArchiveEntry;
+import org.junit.Test;
+
+import java.io.PipedInputStream;
+
+
+/**
+ * Unit tests for class {@link Change}.
+ *
+ * @date 16.06.2017
+ * @see Change
+ **/
+public class ChangeTest {
+
+
+    @Test(expected = NullPointerException.class)
+    public void 
testFailsToCreateChangeTakingFourArgumentsThrowsNullPointerExceptionOne() {
+
+        MemoryArchiveEntry memoryArchiveEntry = new MemoryArchiveEntry("x");
+
+        Change change  = new Change(memoryArchiveEntry, null, false);
+
+    }
+
+
+    @Test(expected = NullPointerException.class)
+    public void 
testFailsToCreateChangeTakingFourArgumentsThrowsNullPointerExceptionTwo() {
+
+        PipedInputStream pipedInputStream = new PipedInputStream(1);
+
+        Change change  = new Change(null, pipedInputStream, false);
+
+    }
+
+
+    @Test(expected = NullPointerException.class)
+    public void 
testFailsToCreateChangeTakingThreeArgumentsThrowsNullPointerException() {
+
+        Change change  = new Change(null, (-407));
+
+    }
+
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3c2419db/src/test/java/org/apache/commons/compress/compressors/xz/XZCompressorOutputStreamTest.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/commons/compress/compressors/xz/XZCompressorOutputStreamTest.java
 
b/src/test/java/org/apache/commons/compress/compressors/xz/XZCompressorOutputStreamTest.java
new file mode 100644
index 0000000..aea5942
--- /dev/null
+++ 
b/src/test/java/org/apache/commons/compress/compressors/xz/XZCompressorOutputStreamTest.java
@@ -0,0 +1,51 @@
+/*
+ * 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.commons.compress.compressors.xz;
+
+import org.junit.Test;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+
+
+/**
+ * Unit tests for class {@link XZCompressorOutputStream}.
+ *
+ * @date 16.06.2017
+ * @see XZCompressorOutputStream
+ **/
+public class XZCompressorOutputStreamTest {
+
+
+    @Test
+    public void testWrite() throws IOException {
+
+        ByteArrayOutputStream byteArrayOutputStream = new 
ByteArrayOutputStream(4590);
+        XZCompressorOutputStream xZCompressorOutputStream = new 
XZCompressorOutputStream(byteArrayOutputStream);
+        xZCompressorOutputStream.write(4590);
+
+        assertEquals(24, byteArrayOutputStream.size());
+        
assertEquals("\uFFFD7zXZ\u0000\u0000\u0004\uFFFD\u05B4F\u0002\u0000!\u0001\u0016\u0000\u0000\u0000t/\uFFFD",
 byteArrayOutputStream.toString());
+
+    }
+
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/3c2419db/src/test/java/org/apache/commons/compress/compressors/z/ZCompressorInputStreamTest.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/commons/compress/compressors/z/ZCompressorInputStreamTest.java
 
b/src/test/java/org/apache/commons/compress/compressors/z/ZCompressorInputStreamTest.java
new file mode 100644
index 0000000..7b9ed54
--- /dev/null
+++ 
b/src/test/java/org/apache/commons/compress/compressors/z/ZCompressorInputStreamTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.commons.compress.compressors.z;
+
+import org.junit.Test;
+
+import java.io.IOException;
+import java.io.SequenceInputStream;
+import java.util.Enumeration;
+
+import static org.mockito.Mockito.mock;
+import static org.powermock.api.mockito.PowerMockito.doReturn;
+
+
+/**
+ * Unit tests for class {@link ZCompressorInputStream}.
+ *
+ * @date 16.06.2017
+ * @see ZCompressorInputStream
+ **/
+public class ZCompressorInputStreamTest {
+
+
+    @Test(expected = IOException.class)
+    public void testFailsToCreateZCompressorInputStreamAndThrowsIOException() 
throws IOException {
+
+        Enumeration<SequenceInputStream> enumeration = 
(Enumeration<SequenceInputStream>) mock(Enumeration.class);
+        SequenceInputStream sequenceInputStream = new 
SequenceInputStream(enumeration);
+        ZCompressorInputStream zCompressorInputStream = null;
+
+        doReturn(false).when(enumeration).hasMoreElements();
+
+        zCompressorInputStream = new 
ZCompressorInputStream(sequenceInputStream);
+
+    }
+
+
+}
\ No newline at end of file

Reply via email to