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


The following commit(s) were added to refs/heads/master by this push:
     new 391eba269 Internal refactoring
391eba269 is described below

commit 391eba269a00b97ffd221c6bb9afedf77890c4ea
Author: Gary Gregory <[email protected]>
AuthorDate: Fri Feb 2 09:23:20 2024 -0500

    Internal refactoring
---
 .../archivers/cpio/CpioArchiveInputStreamTest.java | 32 ++++++++++------------
 1 file changed, 14 insertions(+), 18 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 f1f0e1d4f..ad2e5b506 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
@@ -32,17 +32,25 @@ import org.junit.jupiter.api.Test;
 
 public class CpioArchiveInputStreamTest extends AbstractTest {
 
+    private long consumeEntries(final CpioArchiveInputStream in) throws 
IOException {
+        long count = 0;
+        CpioArchiveEntry entry;
+        while ((entry = in.getNextEntry()) != null) {
+            count++;
+            assertNotNull(entry);
+        }
+        return count;
+    }
+
     @Test
     public void testCpioUnarchive() throws Exception {
         final StringBuilder expected = new StringBuilder();
         expected.append("./test1.xml<?xml version=\"1.0\"?>\n");
         expected.append("<empty/>./test2.xml<?xml version=\"1.0\"?>\n");
         expected.append("<empty/>\n");
-
         final StringBuilder result = new StringBuilder();
         try (CpioArchiveInputStream in = new 
CpioArchiveInputStream(newInputStream("bla.cpio"))) {
             CpioArchiveEntry entry;
-
             while ((entry = in.getNextEntry()) != null) {
                 result.append(entry.getName());
                 int tmp;
@@ -56,31 +64,19 @@ public class CpioArchiveInputStreamTest extends 
AbstractTest {
 
     @Test
     public void testCpioUnarchiveCreatedByRedlineRpm() throws Exception {
-        int count = 0;
+        long count = 0;
         try (CpioArchiveInputStream in = new 
CpioArchiveInputStream(newInputStream("redline.cpio"))) {
-            CpioArchiveEntry entry;
-
-            while ((entry = in.getNextEntry()) != null) {
-                count++;
-                assertNotNull(entry);
-            }
+            count = consumeEntries(in);
         }
-
         assertEquals(count, 1);
     }
 
     @Test
     public void testCpioUnarchiveMultibyteCharName() throws Exception {
-        int count = 0;
+        long count = 0;
         try (CpioArchiveInputStream in = new 
CpioArchiveInputStream(newInputStream("COMPRESS-459.cpio"), 
CharsetNames.UTF_8)) {
-            CpioArchiveEntry entry;
-
-            while ((entry = in.getNextEntry()) != null) {
-                count++;
-                assertNotNull(entry);
-            }
+            count = consumeEntries(in);
         }
-
         assertEquals(2, count);
     }
 

Reply via email to