You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/05/05 18:10:56 UTC

[commons-compress] branch master updated (10076e05 -> 89fd4302)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git


    from 10076e05 Fix broken tests.
     new 97121849 Fix broken tests.
     new 38877c9c Format.
     new 298fa23d Sort members.
     new 91217d29 Format.
     new 51c68bef Sort members.
     new 89fd4302 Fix broken tests.

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../archivers/cpio/CpioArchiveInputStreamTest.java | 50 ++++++++++------------
 .../cpio/CpioArchiveOutputStreamTest.java          | 13 ++----
 .../compress/archivers/cpio/CpioArchiveTest.java   | 16 +++----
 .../compress/archivers/cpio/CpioUtilTest.java      | 40 +++++------------
 .../archivers/tar/TarArchiveEntryTest.java         |  8 ++--
 5 files changed, 49 insertions(+), 78 deletions(-)


[commons-compress] 05/06: Sort members.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 51c68bef1dd80530b52ee115b85955a743bf63ff
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu May 5 14:08:02 2022 -0400

    Sort members.
---
 .../archivers/cpio/CpioArchiveInputStreamTest.java | 42 +++++++++++-----------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStreamTest.java
index 256aaf89..7b17f456 100644
--- a/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStreamTest.java
@@ -31,6 +31,27 @@ import org.junit.jupiter.api.Test;
 
 public class CpioArchiveInputStreamTest extends AbstractTestCase {
 
+    @Test
+    public void multiByteReadConsistentlyReturnsMinusOneAtEof() throws Exception {
+        final byte[] buf = new byte[2];
+        try (InputStream in = Files.newInputStream(getFile("bla.cpio").toPath()); CpioArchiveInputStream archive = new CpioArchiveInputStream(in)) {
+            final ArchiveEntry e = archive.getNextEntry();
+            IOUtils.toByteArray(archive);
+            assertEquals(-1, archive.read(buf));
+            assertEquals(-1, archive.read(buf));
+        }
+    }
+
+    @Test
+    public void singleByteReadConsistentlyReturnsMinusOneAtEof() throws Exception {
+        try (InputStream in = Files.newInputStream(getFile("bla.cpio").toPath()); CpioArchiveInputStream archive = new CpioArchiveInputStream(in)) {
+            final ArchiveEntry e = archive.getNextEntry();
+            IOUtils.toByteArray(archive);
+            assertEquals(-1, archive.read());
+            assertEquals(-1, archive.read());
+        }
+    }
+
     @Test
     public void testCpioUnarchive() throws Exception {
         final StringBuilder expected = new StringBuilder();
@@ -83,25 +104,4 @@ public class CpioArchiveInputStreamTest extends AbstractTestCase {
         assertEquals(2, count);
     }
 
-    @Test
-    public void singleByteReadConsistentlyReturnsMinusOneAtEof() throws Exception {
-        try (InputStream in = Files.newInputStream(getFile("bla.cpio").toPath()); CpioArchiveInputStream archive = new CpioArchiveInputStream(in)) {
-            final ArchiveEntry e = archive.getNextEntry();
-            IOUtils.toByteArray(archive);
-            assertEquals(-1, archive.read());
-            assertEquals(-1, archive.read());
-        }
-    }
-
-    @Test
-    public void multiByteReadConsistentlyReturnsMinusOneAtEof() throws Exception {
-        final byte[] buf = new byte[2];
-        try (InputStream in = Files.newInputStream(getFile("bla.cpio").toPath()); CpioArchiveInputStream archive = new CpioArchiveInputStream(in)) {
-            final ArchiveEntry e = archive.getNextEntry();
-            IOUtils.toByteArray(archive);
-            assertEquals(-1, archive.read(buf));
-            assertEquals(-1, archive.read(buf));
-        }
-    }
-
 }


[commons-compress] 03/06: Sort members.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 298fa23d9516ff604d2346a07189fa22d832d309
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu May 5 14:07:29 2022 -0400

    Sort members.
---
 .../apache/commons/compress/archivers/cpio/CpioUtilTest.java   | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

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 ad25e8b6..18ad6d4d 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
@@ -47,8 +47,9 @@ public class CpioUtilTest {
     }
 
     @Test
-    public void testLong2byteArrayWithZeroThrowsUnsupportedOperationException() {
-        assertThrows(UnsupportedOperationException.class, () -> CpioUtil.long2byteArray(0L, 0, false));
+    public void testByteArray2longThrowsUnsupportedOperationException() {
+        assertThrows(UnsupportedOperationException.class, () -> CpioUtil.byteArray2long(new byte[1], true));
+
     }
 
     @Test
@@ -57,9 +58,8 @@ public class CpioUtilTest {
     }
 
     @Test
-    public void testByteArray2longThrowsUnsupportedOperationException() {
-        assertThrows(UnsupportedOperationException.class, () -> CpioUtil.byteArray2long(new byte[1], true));
-
+    public void testLong2byteArrayWithZeroThrowsUnsupportedOperationException() {
+        assertThrows(UnsupportedOperationException.class, () -> CpioUtil.long2byteArray(0L, 0, false));
     }
 
 }


[commons-compress] 04/06: Format.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 91217d29d7c6caee2cbad8389d36c87ea4d5ca9c
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu May 5 14:07:46 2022 -0400

    Format.
---
 .../archivers/cpio/CpioArchiveInputStreamTest.java       | 12 ++++--------
 .../archivers/cpio/CpioArchiveOutputStreamTest.java      | 13 ++++---------
 .../commons/compress/archivers/cpio/CpioArchiveTest.java | 16 ++++++----------
 3 files changed, 14 insertions(+), 27 deletions(-)

diff --git a/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStreamTest.java
index 57d7ed07..256aaf89 100644
--- a/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStreamTest.java
@@ -56,8 +56,7 @@ public class CpioArchiveInputStreamTest extends AbstractTestCase {
     @Test
     public void testCpioUnarchiveCreatedByRedlineRpm() throws Exception {
         int count = 0;
-        try (final CpioArchiveInputStream in = new CpioArchiveInputStream(
-            Files.newInputStream(getFile("redline.cpio").toPath()))) {
+        try (final CpioArchiveInputStream in = new CpioArchiveInputStream(Files.newInputStream(getFile("redline.cpio").toPath()))) {
             CpioArchiveEntry entry = null;
 
             while ((entry = (CpioArchiveEntry) in.getNextEntry()) != null) {
@@ -72,8 +71,7 @@ public class CpioArchiveInputStreamTest extends AbstractTestCase {
     @Test
     public void testCpioUnarchiveMultibyteCharName() throws Exception {
         int count = 0;
-        try (final CpioArchiveInputStream in = new CpioArchiveInputStream(
-            Files.newInputStream(getFile("COMPRESS-459.cpio").toPath()), "UTF-8")) {
+        try (final CpioArchiveInputStream in = new CpioArchiveInputStream(Files.newInputStream(getFile("COMPRESS-459.cpio").toPath()), "UTF-8")) {
             CpioArchiveEntry entry = null;
 
             while ((entry = (CpioArchiveEntry) in.getNextEntry()) != null) {
@@ -87,8 +85,7 @@ public class CpioArchiveInputStreamTest extends AbstractTestCase {
 
     @Test
     public void singleByteReadConsistentlyReturnsMinusOneAtEof() throws Exception {
-        try (InputStream in = Files.newInputStream(getFile("bla.cpio").toPath());
-             CpioArchiveInputStream archive = new CpioArchiveInputStream(in)) {
+        try (InputStream in = Files.newInputStream(getFile("bla.cpio").toPath()); CpioArchiveInputStream archive = new CpioArchiveInputStream(in)) {
             final ArchiveEntry e = archive.getNextEntry();
             IOUtils.toByteArray(archive);
             assertEquals(-1, archive.read());
@@ -99,8 +96,7 @@ public class CpioArchiveInputStreamTest extends AbstractTestCase {
     @Test
     public void multiByteReadConsistentlyReturnsMinusOneAtEof() throws Exception {
         final byte[] buf = new byte[2];
-        try (InputStream in = Files.newInputStream(getFile("bla.cpio").toPath());
-             CpioArchiveInputStream archive = new CpioArchiveInputStream(in)) {
+        try (InputStream in = Files.newInputStream(getFile("bla.cpio").toPath()); CpioArchiveInputStream archive = new CpioArchiveInputStream(in)) {
             final ArchiveEntry e = archive.getNextEntry();
             IOUtils.toByteArray(archive);
             assertEquals(-1, archive.read(buf));
diff --git a/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStreamTest.java
index 27e27327..08be214a 100644
--- a/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStreamTest.java
@@ -39,12 +39,8 @@ public class CpioArchiveOutputStreamTest extends AbstractTestCase {
         final OutputStream out = Files.newOutputStream(output.toPath());
         InputStream in = null;
         try {
-            final CpioArchiveOutputStream os =
-                new CpioArchiveOutputStream(out, CpioConstants
-                                            .FORMAT_OLD_BINARY);
-            os.putArchiveEntry(new CpioArchiveEntry(CpioConstants
-                                                    .FORMAT_OLD_BINARY,
-                                                    f, "test1.xml"));
+            final CpioArchiveOutputStream os = new CpioArchiveOutputStream(out, CpioConstants.FORMAT_OLD_BINARY);
+            os.putArchiveEntry(new CpioArchiveEntry(CpioConstants.FORMAT_OLD_BINARY, f, "test1.xml"));
             IOUtils.copy(in = Files.newInputStream(f.toPath()), os);
             in.close();
             in = null;
@@ -59,8 +55,7 @@ public class CpioArchiveOutputStreamTest extends AbstractTestCase {
 
         try {
             in = new CpioArchiveInputStream(Files.newInputStream(output.toPath()));
-            final CpioArchiveEntry e = ((CpioArchiveInputStream) in)
-                .getNextCPIOEntry();
+            final CpioArchiveEntry e = ((CpioArchiveInputStream) in).getNextCPIOEntry();
             assertEquals("test1.xml", e.getName());
             assertNull(((CpioArchiveInputStream) in).getNextEntry());
         } finally {
@@ -69,4 +64,4 @@ public class CpioArchiveOutputStreamTest extends AbstractTestCase {
             }
         }
     }
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveTest.java b/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveTest.java
index 7de80559..e5ac295b 100644
--- a/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveTest.java
@@ -31,34 +31,30 @@ import org.junit.jupiter.params.provider.MethodSource;
 public class CpioArchiveTest {
 
     public static Stream<Arguments> factory() {
-        return Stream.of(
-                Arguments.of(CpioConstants.FORMAT_NEW),
-                Arguments.of(CpioConstants.FORMAT_NEW_CRC),
-                Arguments.of(CpioConstants.FORMAT_OLD_ASCII),
-                Arguments.of(CpioConstants.FORMAT_OLD_BINARY));
+        return Stream.of(Arguments.of(CpioConstants.FORMAT_NEW), Arguments.of(CpioConstants.FORMAT_NEW_CRC), Arguments.of(CpioConstants.FORMAT_OLD_ASCII),
+            Arguments.of(CpioConstants.FORMAT_OLD_BINARY));
     }
 
     @ParameterizedTest
     @MethodSource("factory")
     public void utf18RoundtripTest(final short format) throws Exception {
         try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
-            try (CpioArchiveOutputStream os = new CpioArchiveOutputStream(baos, format, CpioConstants.BLOCK_SIZE,
-                "UTF-16LE")) {
+            try (CpioArchiveOutputStream os = new CpioArchiveOutputStream(baos, format, CpioConstants.BLOCK_SIZE, "UTF-16LE")) {
                 final CpioArchiveEntry entry = new CpioArchiveEntry(format, "T\u00e4st.txt", 4);
                 if (format == CpioConstants.FORMAT_NEW_CRC) {
                     entry.setChksum(10);
                 }
                 os.putArchiveEntry(entry);
-                os.write(new byte[] { 1, 2, 3, 4 });
+                os.write(new byte[] {1, 2, 3, 4});
                 os.closeArchiveEntry();
             }
             baos.close();
             try (ByteArrayInputStream bin = new ByteArrayInputStream(baos.toByteArray());
-                 CpioArchiveInputStream in = new CpioArchiveInputStream(bin, "UTF-16LE")) {
+                CpioArchiveInputStream in = new CpioArchiveInputStream(bin, "UTF-16LE")) {
                 final CpioArchiveEntry entry = (CpioArchiveEntry) in.getNextEntry();
                 Assert.assertNotNull(entry);
                 Assert.assertEquals("T\u00e4st.txt", entry.getName());
-                Assert.assertArrayEquals(new byte[] { 1, 2, 3, 4 }, IOUtils.toByteArray(in));
+                Assert.assertArrayEquals(new byte[] {1, 2, 3, 4}, IOUtils.toByteArray(in));
             }
         }
     }


[commons-compress] 06/06: Fix broken tests.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 89fd43021b016ab195b5d89f509e7d51fda35ef3
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu May 5 14:10:51 2022 -0400

    Fix broken tests.
---
 .../commons/compress/archivers/tar/TarArchiveEntryTest.java       | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
index 5af21f68..7d870ff1 100644
--- a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
@@ -242,6 +242,7 @@ public class TarArchiveEntryTest implements TarConstants {
 
     @Test
     public void negativeOffsetInConstructorNotAllowed() throws IOException {
+        // @formatter:off
         byte[] entryContent = ("test1.xml\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
                 "\u0000" +
                 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
@@ -262,7 +263,8 @@ public class TarArchiveEntryTest implements TarConstants {
                 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
                 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
                 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000").getBytes(UTF_8);
-        assertThrows(IOException.class, () -> new TarArchiveEntry(entryContent, ZipEncodingHelper.getZipEncoding(CharsetNames.ISO_8859_1), false, -1));
+        // @formatter:on
+        assertThrows(IllegalArgumentException.class, () -> new TarArchiveEntry(entryContent, ZipEncodingHelper.getZipEncoding(CharsetNames.ISO_8859_1), false, -1));
     }
 
     @Test
@@ -289,7 +291,7 @@ public class TarArchiveEntryTest implements TarConstants {
         final TarArchiveEntry te = new TarArchiveEntry("test");
         te.fillStarSparseData(Collections.singletonMap("SCHILY.realsize", "201"));
         te.setSparseHeaders(Arrays.asList(new TarArchiveStructSparse(10, 5), new TarArchiveStructSparse(12, 1)));
-        te.getOrderedSparseHeaders();
+        assertThrows(IOException.class, () -> te.getOrderedSparseHeaders());
     }
 
     @Test
@@ -297,7 +299,7 @@ public class TarArchiveEntryTest implements TarConstants {
         final TarArchiveEntry te = new TarArchiveEntry("test");
         te.fillStarSparseData(Collections.singletonMap("SCHILY.realsize", String.valueOf(Long.MAX_VALUE)));
         te.setSparseHeaders(Arrays.asList(new TarArchiveStructSparse(Long.MAX_VALUE, 2)));
-        te.getOrderedSparseHeaders();
+        assertThrows(IOException.class, () -> te.getOrderedSparseHeaders());
     }
 
     @Test


[commons-compress] 02/06: Format.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 38877c9cb2502e5446a068569590332715552184
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu May 5 14:07:16 2022 -0400

    Format.
---
 .../compress/archivers/cpio/CpioUtilTest.java      | 22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)

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 1147f22c..ad25e8b6 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
@@ -28,50 +28,38 @@ public class CpioUtilTest {
 
     @Test
     public void oldBinMagic2ByteArrayNotSwapped() {
-        assertArrayEquals(new byte[] { (byte) 0xc7, 0x71 },
-                          CpioUtil.long2byteArray(CpioConstants.MAGIC_OLD_BINARY,
-                                                  2, false));
+        assertArrayEquals(new byte[] {(byte) 0xc7, 0x71}, CpioUtil.long2byteArray(CpioConstants.MAGIC_OLD_BINARY, 2, false));
     }
 
     @Test
     public void oldBinMagic2ByteArraySwapped() {
-        assertArrayEquals(new byte[] { 0x71, (byte) 0xc7,  },
-                          CpioUtil.long2byteArray(CpioConstants.MAGIC_OLD_BINARY,
-                                                  2, true));
+        assertArrayEquals(new byte[] {0x71, (byte) 0xc7,}, CpioUtil.long2byteArray(CpioConstants.MAGIC_OLD_BINARY, 2, true));
     }
 
     @Test
     public void oldBinMagicFromByteArrayNotSwapped() {
-        assertEquals(CpioConstants.MAGIC_OLD_BINARY,
-                     CpioUtil.byteArray2long(new byte[] { (byte) 0xc7, 0x71 },
-                                             false));
+        assertEquals(CpioConstants.MAGIC_OLD_BINARY, CpioUtil.byteArray2long(new byte[] {(byte) 0xc7, 0x71}, false));
     }
 
     @Test
     public void oldBinMagicFromByteArraySwapped() {
-        assertEquals(CpioConstants.MAGIC_OLD_BINARY,
-                     CpioUtil.byteArray2long(new byte[] { 0x71, (byte) 0xc7 },
-                                             true));
+        assertEquals(CpioConstants.MAGIC_OLD_BINARY, CpioUtil.byteArray2long(new byte[] {0x71, (byte) 0xc7}, true));
     }
 
-
     @Test
     public void testLong2byteArrayWithZeroThrowsUnsupportedOperationException() {
         assertThrows(UnsupportedOperationException.class, () -> CpioUtil.long2byteArray(0L, 0, false));
     }
 
-
     @Test
     public void testLong2byteArrayWithPositiveThrowsUnsupportedOperationException() {
         assertThrows(UnsupportedOperationException.class, () -> CpioUtil.long2byteArray(0L, 1021, false));
     }
 
-
     @Test
     public void testByteArray2longThrowsUnsupportedOperationException() {
         assertThrows(UnsupportedOperationException.class, () -> CpioUtil.byteArray2long(new byte[1], true));
 
     }
 
-
-}
\ No newline at end of file
+}


[commons-compress] 01/06: Fix broken tests.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 9712184925ce7a0367127f671be383b023819de6
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu May 5 14:07:07 2022 -0400

    Fix broken tests.
---
 .../commons/compress/archivers/cpio/CpioUtilTest.java      | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

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 f453c00f..1147f22c 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
@@ -22,6 +22,7 @@ import org.junit.jupiter.api.Test;
 
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
 
 public class CpioUtilTest {
 
@@ -56,26 +57,19 @@ public class CpioUtilTest {
 
     @Test
     public void testLong2byteArrayWithZeroThrowsUnsupportedOperationException() {
-
-        CpioUtil.long2byteArray(0L, 0, false);
-
+        assertThrows(UnsupportedOperationException.class, () -> CpioUtil.long2byteArray(0L, 0, false));
     }
 
 
     @Test
     public void testLong2byteArrayWithPositiveThrowsUnsupportedOperationException() {
-
-        CpioUtil.long2byteArray(0L, 1021, false);
-
+        assertThrows(UnsupportedOperationException.class, () -> CpioUtil.long2byteArray(0L, 1021, false));
     }
 
 
     @Test
     public void testByteArray2longThrowsUnsupportedOperationException() {
-
-        final byte[] byteArray = new byte[1];
-
-        CpioUtil.byteArray2long(byteArray, true);
+        assertThrows(UnsupportedOperationException.class, () -> CpioUtil.byteArray2long(new byte[1], true));
 
     }