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 2024/11/26 15:09:13 UTC

(commons-compress) branch master updated (d9798601b -> d9939e802)

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 d9798601b Optimize ZipEightByteInteger #614
     new 332412363 Sort members
     new d9939e802 Clean up static imports

The 2 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/zip/ZipEightByteInteger.java         | 22 ++++++-------
 .../archivers/zip/ZipEightByteIntegerTest.java     | 38 +++++++++++-----------
 .../gzip/GzipCompressorOutputStreamTest.java       |  2 +-
 .../apache/commons/compress/utils/IOUtilsTest.java | 10 +++---
 4 files changed, 36 insertions(+), 36 deletions(-)


(commons-compress) 02/02: Clean up static imports

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 d9939e802895c95114bef374cb95cfd39a1ac256
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Nov 26 10:08:57 2024 -0500

    Clean up static imports
---
 .../compress/compressors/gzip/GzipCompressorOutputStreamTest.java       | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/test/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStreamTest.java b/src/test/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStreamTest.java
index e6069a79d..6c6c311e5 100644
--- a/src/test/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStreamTest.java
@@ -23,8 +23,8 @@ import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertSame;
-import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.fail;
 import static org.junit.jupiter.api.Assumptions.assumeTrue;
 


(commons-compress) 01/02: 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 33241236314b6953e031c200f7a9d65982cedcb7
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Nov 26 10:08:22 2024 -0500

    Sort members
---
 .../archivers/zip/ZipEightByteInteger.java         | 22 ++++++-------
 .../archivers/zip/ZipEightByteIntegerTest.java     | 38 +++++++++++-----------
 .../apache/commons/compress/utils/IOUtilsTest.java | 10 +++---
 3 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipEightByteInteger.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipEightByteInteger.java
index 96fd1c54e..61680accb 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipEightByteInteger.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipEightByteInteger.java
@@ -35,17 +35,6 @@ public final class ZipEightByteInteger implements Serializable {
 
     private static final BigInteger HIGHEST_BIT = BigInteger.ONE.shiftLeft(63);
 
-    /**
-     * package private for tests only.
-     */
-    static BigInteger toUnsignedBigInteger(final long value) {
-        if (value >= 0L) {
-            return BigInteger.valueOf(value);
-        } else {
-            return BigInteger.valueOf(value & Long.MAX_VALUE).add(HIGHEST_BIT);
-        }
-    }
-
     /**
      * Gets value as eight bytes in big-endian byte order.
      *
@@ -110,6 +99,17 @@ public final class ZipEightByteInteger implements Serializable {
         return toUnsignedBigInteger(getLongValue(bytes, offset));
     }
 
+    /**
+     * package private for tests only.
+     */
+    static BigInteger toUnsignedBigInteger(final long value) {
+        if (value >= 0L) {
+            return BigInteger.valueOf(value);
+        } else {
+            return BigInteger.valueOf(value & Long.MAX_VALUE).add(HIGHEST_BIT);
+        }
+    }
+
     private final long value;
 
     /**
diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ZipEightByteIntegerTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ZipEightByteIntegerTest.java
index 144244cd4..a80cb753a 100644
--- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipEightByteIntegerTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipEightByteIntegerTest.java
@@ -29,15 +29,6 @@ import org.junit.jupiter.api.Test;
  */
 public class ZipEightByteIntegerTest {
 
-    /**
-     * Test {@link ZipEightByteInteger#toUnsignedBigInteger(long)}.
-     */
-    @Test
-    public void testToUnsignedBigInteger() {
-        assertEquals(BigInteger.valueOf(Long.MAX_VALUE), ZipEightByteInteger.toUnsignedBigInteger(Long.MAX_VALUE));
-        assertEquals(BigInteger.valueOf(Long.MAX_VALUE).shiftLeft(1), ZipEightByteInteger.toUnsignedBigInteger(0XFFFFFFFFFFFFFFFEL));
-    }
-
     /**
      * Test conversion from bytes.
      */
@@ -60,6 +51,16 @@ public class ZipEightByteIntegerTest {
         assertEquals("18446744073709551615", zipEightByteInteger.getValue().toString());
     }
 
+    /**
+     * Test conversion from bytes.
+     */
+    @Test
+    public void testBILongFromBytes() {
+        final byte[] val = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
+        final ZipEightByteInteger zl = new ZipEightByteInteger(val);
+        assertEquals(0XFFFFFFFFFFFFFFFFL, zl.getLongValue(), "longValue from bytes");
+    }
+
     /**
      * Test conversion to bytes.
      */
@@ -108,16 +109,6 @@ public class ZipEightByteIntegerTest {
         assertEquals(0xAB12345678L, zl.getLongValue(), "longValue from bytes");
     }
 
-    /**
-     * Test conversion from bytes.
-     */
-    @Test
-    public void testBILongFromBytes() {
-        final byte[] val = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
-        final ZipEightByteInteger zl = new ZipEightByteInteger(val);
-        assertEquals(0XFFFFFFFFFFFFFFFFL, zl.getLongValue(), "longValue from bytes");
-    }
-
     /**
      * Test conversion to bytes.
      */
@@ -155,4 +146,13 @@ public class ZipEightByteIntegerTest {
                 new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF });
         assertEquals("ZipEightByteInteger value: 18446744073709551615", zipEightByteInteger.toString());
     }
+
+    /**
+     * Test {@link ZipEightByteInteger#toUnsignedBigInteger(long)}.
+     */
+    @Test
+    public void testToUnsignedBigInteger() {
+        assertEquals(BigInteger.valueOf(Long.MAX_VALUE), ZipEightByteInteger.toUnsignedBigInteger(Long.MAX_VALUE));
+        assertEquals(BigInteger.valueOf(Long.MAX_VALUE).shiftLeft(1), ZipEightByteInteger.toUnsignedBigInteger(0XFFFFFFFFFFFFFFFEL));
+    }
 }
diff --git a/src/test/java/org/apache/commons/compress/utils/IOUtilsTest.java b/src/test/java/org/apache/commons/compress/utils/IOUtilsTest.java
index 2410dc9f2..442de9b98 100644
--- a/src/test/java/org/apache/commons/compress/utils/IOUtilsTest.java
+++ b/src/test/java/org/apache/commons/compress/utils/IOUtilsTest.java
@@ -80,6 +80,11 @@ public class IOUtilsTest {
         assertThrows(NullPointerException.class, () -> IOUtils.copy(in, (OutputStream) null));
     }
 
+    @Test
+    public void testCopyOnZeroBufferSize() throws IOException {
+        assertEquals(0, IOUtils.copy(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY), new ByteArrayOutputStream(), 0));
+    }
+
     @Test
     public void testCopyRangeDoesntCopyMoreThanAskedFor() throws IOException {
         try (ByteArrayInputStream in = new ByteArrayInputStream(new byte[] { 1, 2, 3, 4, 5 });
@@ -106,11 +111,6 @@ public class IOUtilsTest {
                 () -> IOUtils.copyRange(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY), 5, new ByteArrayOutputStream(), 0));
     }
 
-    @Test
-    public void testCopyOnZeroBufferSize() throws IOException {
-        assertEquals(0, IOUtils.copy(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY), new ByteArrayOutputStream(), 0));
-    }
-
     @Test
     public void testReadFullyOnChannelReadsFully() throws IOException {
         final ByteBuffer b = ByteBuffer.allocate(20);