You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2017/06/17 08:21:59 UTC
[1/7] commons-compress git commit: add-some-Unit-Tests Added
additional Unit Tests.
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 <mi...@tugraz.at>
Authored: Fri Jun 16 22:16:06 2017 +0200
Committer: Stefan Bodewig <bo...@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
[4/7] commons-compress git commit: add-some-Unit-Tests Added some
Unit Tests to increase code coverage.
Posted by bo...@apache.org.
add-some-Unit-Tests Added some Unit Tests to increase code coverage.
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/b861b4f0
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/b861b4f0
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/b861b4f0
Branch: refs/heads/master
Commit: b861b4f0e45135e737e1ec2a514d3051157c3c7b
Parents: 7254daa
Author: Michael Hausegger <mi...@tugraz.at>
Authored: Tue Jun 13 23:47:50 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sat Jun 17 10:20:10 2017 +0200
----------------------------------------------------------------------
.../commons/compress/ArchiveUtilsTest.java | 52 +++++++-
.../ChecksumCalculatingInputStreamTest.java | 122 +++++++++++++++++++
.../utils/ChecksumVerifyingInputStreamTest.java | 87 +++++++++++++
.../utils/ServiceLoaderIteratorTest.java | 74 +++++++++++
4 files changed, 333 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/b861b4f0/src/test/java/org/apache/commons/compress/ArchiveUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/ArchiveUtilsTest.java b/src/test/java/org/apache/commons/compress/ArchiveUtilsTest.java
index 5dc7925..54a2451 100644
--- a/src/test/java/org/apache/commons/compress/ArchiveUtilsTest.java
+++ b/src/test/java/org/apache/commons/compress/ArchiveUtilsTest.java
@@ -18,11 +18,12 @@
package org.apache.commons.compress;
-import static org.junit.Assert.*;
-
+import org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry;
import org.apache.commons.compress.utils.ArchiveUtils;
import org.junit.Test;
+import static org.junit.Assert.*;
+
public class ArchiveUtilsTest extends AbstractTestCase {
private static final int bytesToTest = 50;
@@ -95,6 +96,53 @@ public class ArchiveUtilsTest extends AbstractTestCase {
assertEquals(expected, ArchiveUtils.sanitize(input));
}
+ @Test
+ public void testIsEqualWithNullWithPositive() {
+
+ byte[] byteArray = new byte[8];
+ byteArray[1] = (byte) (-77);
+
+ assertFalse(ArchiveUtils.isEqualWithNull(byteArray, 0, (byte)0, byteArray, (byte)0, (byte)80));
+
+ }
+
+ @Test
+ public void testToAsciiBytes() {
+
+ byte[] byteArray = ArchiveUtils.toAsciiBytes("SOCKET");
+
+ assertArrayEquals(new byte[] {(byte)83, (byte)79, (byte)67, (byte)75, (byte)69, (byte)84}, byteArray);
+
+ assertFalse(ArchiveUtils.isEqualWithNull(byteArray, 0, 46, byteArray, 63, 0));
+
+ }
+
+ @Test
+ public void testToStringWithNonNull() {
+
+ SevenZArchiveEntry sevenZArchiveEntry = new SevenZArchiveEntry();
+ String string = ArchiveUtils.toString(sevenZArchiveEntry);
+
+ assertEquals("- 0 null", string);
+
+ }
+
+ @Test
+ public void testIsEqual() {
+
+ assertTrue(ArchiveUtils.isEqual((byte[]) null, 0, 0, (byte[]) null, 0, 0));
+
+ }
+
+ @Test(expected = StringIndexOutOfBoundsException.class)
+ public void testToAsciiStringThrowsStringIndexOutOfBoundsException() {
+
+ byte[] byteArray = new byte[3];
+
+ ArchiveUtils.toAsciiString(byteArray, 940, 2730);
+
+ }
+
private void asciiToByteAndBackOK(final String inputString) {
assertEquals(inputString, ArchiveUtils.toAsciiString(ArchiveUtils.toAsciiBytes(inputString)));
}
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/b861b4f0/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java b/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java
new file mode 100644
index 0000000..09133d3
--- /dev/null
+++ b/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java
@@ -0,0 +1,122 @@
+/*
+ * 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.utils;
+
+import org.junit.Test;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.zip.Adler32;
+
+import static org.junit.Assert.*;
+
+/**
+ * Unit tests for class {@link ChecksumCalculatingInputStream org.apache.commons.compress.utils.ChecksumCalculatingInputStream}.
+ *
+ * @author Michael Hausegger, hausegger.michael@googlemail.com
+ * @date 13.06.2017
+ * @see ChecksumCalculatingInputStream
+ **/
+public class ChecksumCalculatingInputStreamTest {
+
+
+
+ @Test
+ public void testSkipReturningZero() throws IOException {
+
+ Adler32 adler32_ = new Adler32();
+ byte[] byteArray = new byte[0];
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
+ ChecksumCalculatingInputStream checksumCalculatingInputStream = new ChecksumCalculatingInputStream(adler32_, byteArrayInputStream);
+ long skipResult = checksumCalculatingInputStream.skip(60L);
+
+ assertEquals(0L, skipResult);
+
+ assertEquals(1L, checksumCalculatingInputStream.getValue());
+
+
+ }
+
+
+ @Test
+ public void testSkipReturningPositive() throws IOException {
+
+ Adler32 adler32_ = new Adler32();
+ byte[] byteArray = new byte[6];
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
+ ChecksumCalculatingInputStream checksumCalculatingInputStream = new ChecksumCalculatingInputStream(adler32_, byteArrayInputStream);
+ long skipResult = checksumCalculatingInputStream.skip((byte)0);
+
+ assertEquals(1L, skipResult);
+
+ assertEquals(65537L, checksumCalculatingInputStream.getValue());
+
+ }
+
+
+ @Test
+ public void testReadTakingNoArguments() throws IOException {
+
+ Adler32 adler32_ = new Adler32();
+ byte[] byteArray = new byte[6];
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
+ ChecksumCalculatingInputStream checksumCalculatingInputStream = new ChecksumCalculatingInputStream(adler32_, byteArrayInputStream);
+ BufferedInputStream bufferedInputStream = new BufferedInputStream(checksumCalculatingInputStream);
+ int inputStreamReadResult = bufferedInputStream.read(byteArray, 0, 1);
+ int checkSumCalculationReadResult = checksumCalculatingInputStream.read();
+
+ assertFalse(checkSumCalculationReadResult == inputStreamReadResult);
+ assertEquals((-1), checkSumCalculationReadResult);
+
+ assertEquals(0, byteArrayInputStream.available());
+
+ assertEquals(393217L, checksumCalculatingInputStream.getValue());
+
+ }
+
+
+ @Test(expected = NullPointerException.class) //I assume this behaviour to be a bug or at least a defect.
+ public void testGetValueThrowsNullPointerException() {
+
+ ChecksumCalculatingInputStream checksumCalculatingInputStream = new ChecksumCalculatingInputStream(null,null);
+
+ checksumCalculatingInputStream.getValue();
+
+
+ }
+
+
+ @Test
+ public void testReadTakingByteArray() throws IOException {
+
+ Adler32 adler32_ = new Adler32();
+ byte[] byteArray = new byte[6];
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
+ ChecksumCalculatingInputStream checksumCalculatingInputStream = new ChecksumCalculatingInputStream(adler32_, byteArrayInputStream);
+ int readResult = checksumCalculatingInputStream.read(byteArray);
+
+ assertEquals(6, readResult);
+
+ assertEquals(0, byteArrayInputStream.available());
+ assertEquals(393217L, checksumCalculatingInputStream.getValue());
+
+ }
+
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/b861b4f0/src/test/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStreamTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStreamTest.java b/src/test/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStreamTest.java
new file mode 100644
index 0000000..e63d6aa
--- /dev/null
+++ b/src/test/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStreamTest.java
@@ -0,0 +1,87 @@
+/*
+ * 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.utils;
+
+import org.junit.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.zip.Adler32;
+import java.util.zip.CRC32;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit tests for class {@link ChecksumVerifyingInputStream org.apache.commons.compress.utils.ChecksumVerifyingInputStream}.
+ *
+ * @author Michael Hausegger, hausegger.michael@googlemail.com
+ * @date 13.06.2017
+ * @see ChecksumVerifyingInputStream
+ **/
+public class ChecksumVerifyingInputStreamTest {
+
+
+
+ @Test(expected = IOException.class)
+ public void testReadTakingByteArrayThrowsIOException() throws IOException {
+
+ Adler32 adler32_ = new Adler32();
+ byte[] byteArray = new byte[3];
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
+ ChecksumVerifyingInputStream checksumVerifyingInputStream = new ChecksumVerifyingInputStream(adler32_, byteArrayInputStream, (-1859L), (byte) (-68));
+
+ checksumVerifyingInputStream.read(byteArray);
+
+ }
+
+
+ @Test(expected = IOException.class)
+ public void testReadTakingNoArgumentsThrowsIOException() throws IOException {
+
+ CRC32 cRC32_ = new CRC32();
+ byte[] byteArray = new byte[9];
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
+ ChecksumVerifyingInputStream checksumVerifyingInputStream = new ChecksumVerifyingInputStream(cRC32_, byteArrayInputStream, (byte)1, (byte)1);
+
+ checksumVerifyingInputStream.read();
+
+ }
+
+
+ @Test
+ public void testSkip() throws IOException {
+
+ CRC32 cRC32_ = new CRC32();
+ byte[] byteArray = new byte[4];
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
+ ChecksumVerifyingInputStream checksumVerifyingInputStream = new ChecksumVerifyingInputStream(cRC32_, byteArrayInputStream, (byte)33, 2303L);
+ int intOne = checksumVerifyingInputStream.read(byteArray);
+
+ long skipReturnValue = checksumVerifyingInputStream.skip((byte)1);
+
+ assertEquals(558161692L, cRC32_.getValue());
+ assertEquals(0, byteArrayInputStream.available());
+
+ assertArrayEquals(new byte[] {(byte)0, (byte)0, (byte)0, (byte)0}, byteArray);
+ assertEquals(0L, skipReturnValue);
+
+ }
+
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/b861b4f0/src/test/java/org/apache/commons/compress/utils/ServiceLoaderIteratorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/utils/ServiceLoaderIteratorTest.java b/src/test/java/org/apache/commons/compress/utils/ServiceLoaderIteratorTest.java
new file mode 100644
index 0000000..0aa1248
--- /dev/null
+++ b/src/test/java/org/apache/commons/compress/utils/ServiceLoaderIteratorTest.java
@@ -0,0 +1,74 @@
+/*
+ * 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.utils;
+
+import org.junit.Test;
+
+import java.util.NoSuchElementException;
+
+import static org.junit.Assert.assertFalse;
+
+/**
+ * Unit tests for class {@link ServiceLoaderIterator org.apache.commons.compress.utils.ServiceLoaderIterator}.
+ *
+ * @author Michael Hausegger, hausegger.michael@googlemail.com
+ * @date 13.06.2017
+ * @see ServiceLoaderIterator
+ **/
+public class ServiceLoaderIteratorTest {
+
+
+
+ @Test(expected = NoSuchElementException.class)
+ public void testNextThrowsNoSuchElementException() {
+
+ Class<String> clasz = String.class;
+ ServiceLoaderIterator<String> serviceLoaderIterator = new ServiceLoaderIterator<String>(clasz);
+
+ serviceLoaderIterator.next();
+
+ }
+
+
+ @Test
+ public void testHasNextReturnsFalse() {
+
+ Class<Object> clasz = Object.class;
+ ServiceLoaderIterator<Object> serviceLoaderIterator = new ServiceLoaderIterator<Object>(clasz);
+ boolean result = serviceLoaderIterator.hasNext();
+
+ assertFalse(result);
+
+ }
+
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testRemoveThrowsUnsupportedOperationException() {
+
+ Class<Integer> clasz = Integer.class;
+ ServiceLoaderIterator<Integer> serviceLoaderIterator = new ServiceLoaderIterator<Integer>(clasz);
+
+ serviceLoaderIterator.remove();
+
+
+ }
+
+
+
+}
\ No newline at end of file
[5/7] commons-compress git commit: add-some-Unit-Tests Removed test
testGetValueThrowsNullPointerException in class
ChecksumCalculatingInputStreamTest. Test represented a bug/defect which is
going to be fixed in a different branch.
Posted by bo...@apache.org.
add-some-Unit-Tests Removed test testGetValueThrowsNullPointerException in class ChecksumCalculatingInputStreamTest. Test represented a bug/defect which is going to be fixed in a different branch.
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/6fe9ae88
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/6fe9ae88
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/6fe9ae88
Branch: refs/heads/master
Commit: 6fe9ae88052b89dbf67468776a725b0dac57422a
Parents: b5848b2
Author: Michael Hausegger <mi...@tugraz.at>
Authored: Fri Jun 16 20:22:10 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sat Jun 17 10:20:10 2017 +0200
----------------------------------------------------------------------
.../utils/ChecksumCalculatingInputStreamTest.java | 11 -----------
1 file changed, 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/6fe9ae88/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java b/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java
index ee47798..089c685 100644
--- a/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java
@@ -89,17 +89,6 @@ public class ChecksumCalculatingInputStreamTest {
}
- @Test(expected = NullPointerException.class) //I assume this behaviour to be a bug or at least a defect.
- public void testGetValueThrowsNullPointerException() {
-
- ChecksumCalculatingInputStream checksumCalculatingInputStream = new ChecksumCalculatingInputStream(null,null);
-
- checksumCalculatingInputStream.getValue();
-
-
- }
-
-
@Test
public void testReadTakingByteArray() throws IOException {
[2/7] commons-compress git commit: add-some-Unit-Tests Added myself
as contributor to pom.xml as "requested" by Stefan Bodewig.
Posted by bo...@apache.org.
add-some-Unit-Tests Added myself as contributor to pom.xml as "requested" by Stefan Bodewig.
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/cf9f45bc
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/cf9f45bc
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/cf9f45bc
Branch: refs/heads/master
Commit: cf9f45bc545fced1647fa8aed01f504dfa35718f
Parents: 496691b
Author: Michael Hausegger <mi...@tugraz.at>
Authored: Fri Jun 16 20:44:40 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sat Jun 17 10:20:10 2017 +0200
----------------------------------------------------------------------
pom.xml | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/cf9f45bc/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 63d092e..fdf1721 100644
--- a/pom.xml
+++ b/pom.xml
@@ -169,6 +169,10 @@ jar, tar, zip, dump, 7z, arj.
<contributor>
<name>BELUGA BEHR</name>
</contributor>
+ <contributor>
+ <name>Michael Hausegger</name>
+ <email>hausegger.michael@googlemail.com</email>
+ </contributor>
</contributors>
<scm>
[6/7] commons-compress git commit: add-some-Unit-Tests Minor variable
renaming.
Posted by bo...@apache.org.
add-some-Unit-Tests Minor variable renaming.
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/496691bf
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/496691bf
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/496691bf
Branch: refs/heads/master
Commit: 496691bfd82374f1c1bfee8719309343c2fa878d
Parents: 6fe9ae8
Author: Michael Hausegger <mi...@tugraz.at>
Authored: Fri Jun 16 20:38:00 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sat Jun 17 10:20:10 2017 +0200
----------------------------------------------------------------------
.../utils/ChecksumCalculatingInputStreamTest.java | 16 ++++++++--------
.../utils/ChecksumVerifyingInputStreamTest.java | 4 ++--
2 files changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/496691bf/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java b/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java
index 089c685..b97b09e 100644
--- a/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java
@@ -38,10 +38,10 @@ public class ChecksumCalculatingInputStreamTest {
@Test
public void testSkipReturningZero() throws IOException {
- Adler32 adler32_ = new Adler32();
+ Adler32 adler32 = new Adler32();
byte[] byteArray = new byte[0];
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
- ChecksumCalculatingInputStream checksumCalculatingInputStream = new ChecksumCalculatingInputStream(adler32_, byteArrayInputStream);
+ ChecksumCalculatingInputStream checksumCalculatingInputStream = new ChecksumCalculatingInputStream(adler32, byteArrayInputStream);
long skipResult = checksumCalculatingInputStream.skip(60L);
assertEquals(0L, skipResult);
@@ -55,10 +55,10 @@ public class ChecksumCalculatingInputStreamTest {
@Test
public void testSkipReturningPositive() throws IOException {
- Adler32 adler32_ = new Adler32();
+ Adler32 adler32 = new Adler32();
byte[] byteArray = new byte[6];
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
- ChecksumCalculatingInputStream checksumCalculatingInputStream = new ChecksumCalculatingInputStream(adler32_, byteArrayInputStream);
+ ChecksumCalculatingInputStream checksumCalculatingInputStream = new ChecksumCalculatingInputStream(adler32, byteArrayInputStream);
long skipResult = checksumCalculatingInputStream.skip((byte)0);
assertEquals(1L, skipResult);
@@ -71,10 +71,10 @@ public class ChecksumCalculatingInputStreamTest {
@Test
public void testReadTakingNoArguments() throws IOException {
- Adler32 adler32_ = new Adler32();
+ Adler32 adler32 = new Adler32();
byte[] byteArray = new byte[6];
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
- ChecksumCalculatingInputStream checksumCalculatingInputStream = new ChecksumCalculatingInputStream(adler32_, byteArrayInputStream);
+ ChecksumCalculatingInputStream checksumCalculatingInputStream = new ChecksumCalculatingInputStream(adler32, byteArrayInputStream);
BufferedInputStream bufferedInputStream = new BufferedInputStream(checksumCalculatingInputStream);
int inputStreamReadResult = bufferedInputStream.read(byteArray, 0, 1);
int checkSumCalculationReadResult = checksumCalculatingInputStream.read();
@@ -92,10 +92,10 @@ public class ChecksumCalculatingInputStreamTest {
@Test
public void testReadTakingByteArray() throws IOException {
- Adler32 adler32_ = new Adler32();
+ Adler32 adler32 = new Adler32();
byte[] byteArray = new byte[6];
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
- ChecksumCalculatingInputStream checksumCalculatingInputStream = new ChecksumCalculatingInputStream(adler32_, byteArrayInputStream);
+ ChecksumCalculatingInputStream checksumCalculatingInputStream = new ChecksumCalculatingInputStream(adler32, byteArrayInputStream);
int readResult = checksumCalculatingInputStream.read(byteArray);
assertEquals(6, readResult);
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/496691bf/src/test/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStreamTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStreamTest.java b/src/test/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStreamTest.java
index 63a1d11..cc9b100 100644
--- a/src/test/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStreamTest.java
@@ -39,10 +39,10 @@ public class ChecksumVerifyingInputStreamTest {
@Test(expected = IOException.class)
public void testReadTakingByteArrayThrowsIOException() throws IOException {
- Adler32 adler32_ = new Adler32();
+ Adler32 adler32 = new Adler32();
byte[] byteArray = new byte[3];
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
- ChecksumVerifyingInputStream checksumVerifyingInputStream = new ChecksumVerifyingInputStream(adler32_, byteArrayInputStream, (-1859L), (byte) (-68));
+ ChecksumVerifyingInputStream checksumVerifyingInputStream = new ChecksumVerifyingInputStream(adler32, byteArrayInputStream, (-1859L), (byte) (-68));
checksumVerifyingInputStream.read(byteArray);
[7/7] commons-compress git commit: closes #33, thanks @TheRealHaui
Posted by bo...@apache.org.
closes #33, thanks @TheRealHaui
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/0960a387
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/0960a387
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/0960a387
Branch: refs/heads/master
Commit: 0960a387c00bf0409412bc283b3ee7fab963f718
Parents: 3c2419d
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sat Jun 17 10:21:17 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sat Jun 17 10:21:17 2017 +0200
----------------------------------------------------------------------
----------------------------------------------------------------------
[3/7] commons-compress git commit: add-some-Unit-Tests Removed
@author tags in comments.
Posted by bo...@apache.org.
add-some-Unit-Tests Removed @author tags in comments.
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/b5848b2f
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/b5848b2f
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/b5848b2f
Branch: refs/heads/master
Commit: b5848b2f1f8b49502dbe5255128a70ca5c3abb06
Parents: b861b4f
Author: Michael Hausegger <mi...@tugraz.at>
Authored: Fri Jun 16 20:12:20 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sat Jun 17 10:20:10 2017 +0200
----------------------------------------------------------------------
.../commons/compress/utils/ChecksumCalculatingInputStreamTest.java | 1 -
.../commons/compress/utils/ChecksumVerifyingInputStreamTest.java | 1 -
.../apache/commons/compress/utils/ServiceLoaderIteratorTest.java | 1 -
3 files changed, 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/b5848b2f/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java b/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java
index 09133d3..ee47798 100644
--- a/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java
@@ -28,7 +28,6 @@ import static org.junit.Assert.*;
/**
* Unit tests for class {@link ChecksumCalculatingInputStream org.apache.commons.compress.utils.ChecksumCalculatingInputStream}.
*
- * @author Michael Hausegger, hausegger.michael@googlemail.com
* @date 13.06.2017
* @see ChecksumCalculatingInputStream
**/
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/b5848b2f/src/test/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStreamTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStreamTest.java b/src/test/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStreamTest.java
index e63d6aa..63a1d11 100644
--- a/src/test/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/utils/ChecksumVerifyingInputStreamTest.java
@@ -29,7 +29,6 @@ import static org.junit.Assert.assertEquals;
/**
* Unit tests for class {@link ChecksumVerifyingInputStream org.apache.commons.compress.utils.ChecksumVerifyingInputStream}.
*
- * @author Michael Hausegger, hausegger.michael@googlemail.com
* @date 13.06.2017
* @see ChecksumVerifyingInputStream
**/
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/b5848b2f/src/test/java/org/apache/commons/compress/utils/ServiceLoaderIteratorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/utils/ServiceLoaderIteratorTest.java b/src/test/java/org/apache/commons/compress/utils/ServiceLoaderIteratorTest.java
index 0aa1248..c39f401 100644
--- a/src/test/java/org/apache/commons/compress/utils/ServiceLoaderIteratorTest.java
+++ b/src/test/java/org/apache/commons/compress/utils/ServiceLoaderIteratorTest.java
@@ -27,7 +27,6 @@ import static org.junit.Assert.assertFalse;
/**
* Unit tests for class {@link ServiceLoaderIterator org.apache.commons.compress.utils.ServiceLoaderIterator}.
*
- * @author Michael Hausegger, hausegger.michael@googlemail.com
* @date 13.06.2017
* @see ServiceLoaderIterator
**/