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 <garydgreg...@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)); } } }