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 2023/11/12 14:50:27 UTC
(commons-compress) branch master updated (7c05807e0 -> 9b86b1f2b)
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 7c05807e0 Camel-case parameter names
new 539cc1a1a Use final
new 9b86b1f2b Simplify
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:
.../lz4/FramedLZ4CompressorOutputStreamTest.java | 47 ++++++++++------------
1 file changed, 21 insertions(+), 26 deletions(-)
(commons-compress) 01/02: Use final
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 539cc1a1a8399e7355b0877c3253261c3c889de0
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Nov 12 09:49:15 2023 -0500
Use final
- Sort members
- Format nits
---
.../lz4/FramedLZ4CompressorOutputStreamTest.java | 47 ++++++++++------------
1 file changed, 22 insertions(+), 25 deletions(-)
diff --git a/src/test/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorOutputStreamTest.java b/src/test/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorOutputStreamTest.java
index 97fee10a6..4ead6657f 100644
--- a/src/test/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorOutputStreamTest.java
@@ -25,42 +25,39 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
public class FramedLZ4CompressorOutputStreamTest {
-
+
+ @Test
+ public void testFinishWithNoWrite() throws IOException {
+ final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ try (FramedLZ4CompressorOutputStream compressor = new FramedLZ4CompressorOutputStream(buffer,
+ new FramedLZ4CompressorOutputStream.Parameters(FramedLZ4CompressorOutputStream.BlockSize.K64, true, false, false))) {
+ // do nothing here. this will test that flush on close doesn't throw any exceptions if no data is written.
+ }
+ assertTrue(buffer.size() == 15, "only the trailer gets written.");
+ }
+
@Test
public void testWriteByteArrayVsWriteByte() throws IOException {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
sb.append("abcdefghijklmnop");
- byte[] random = sb.toString().getBytes();
- try (FramedLZ4CompressorOutputStream compressor =
- new FramedLZ4CompressorOutputStream(buffer,
- new FramedLZ4CompressorOutputStream.Parameters(FramedLZ4CompressorOutputStream.BlockSize.K64, true, false, false))) {
+ final byte[] random = sb.toString().getBytes();
+ try (FramedLZ4CompressorOutputStream compressor = new FramedLZ4CompressorOutputStream(buffer,
+ new FramedLZ4CompressorOutputStream.Parameters(FramedLZ4CompressorOutputStream.BlockSize.K64, true, false, false))) {
compressor.write(random);
compressor.finish();
}
- byte[] bulkOutput = buffer.toByteArray();
+ final byte[] bulkOutput = buffer.toByteArray();
buffer = new ByteArrayOutputStream();
- try (FramedLZ4CompressorOutputStream compressor =
- new FramedLZ4CompressorOutputStream(buffer,
- new FramedLZ4CompressorOutputStream.Parameters(FramedLZ4CompressorOutputStream.BlockSize.K64, true, false, false))) {
- for (int i = 0; i < random.length; i++) {
- compressor.write(random[i]);
+ try (FramedLZ4CompressorOutputStream compressor = new FramedLZ4CompressorOutputStream(buffer,
+ new FramedLZ4CompressorOutputStream.Parameters(FramedLZ4CompressorOutputStream.BlockSize.K64, true, false, false))) {
+ for (final byte element : random) {
+ compressor.write(element);
}
compressor.finish();
}
- byte[] singleOutput = buffer.toByteArray();
+ final byte[] singleOutput = buffer.toByteArray();
assertTrue(Arrays.equals(bulkOutput, singleOutput));
}
-
- @Test
- public void testFinishWithNoWrite() throws IOException {
- ByteArrayOutputStream buffer = new ByteArrayOutputStream();
- try (FramedLZ4CompressorOutputStream compressor =
- new FramedLZ4CompressorOutputStream(buffer,
- new FramedLZ4CompressorOutputStream.Parameters(FramedLZ4CompressorOutputStream.BlockSize.K64, true, false, false))) {
- // do nothing here. this will test that flush on close doesn't throw any exceptions if no data is written.
- }
- assertTrue(buffer.size() == 15, "only the trailer gets written.");
- }
-
+
}
(commons-compress) 02/02: Simplify
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 9b86b1f2bb37a839af8164795e88d4d46544da43
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Nov 12 09:50:21 2023 -0500
Simplify
---
.../compress/compressors/lz4/FramedLZ4CompressorOutputStreamTest.java | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/test/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorOutputStreamTest.java b/src/test/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorOutputStreamTest.java
index 4ead6657f..35f66ae7a 100644
--- a/src/test/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/compressors/lz4/FramedLZ4CompressorOutputStreamTest.java
@@ -39,9 +39,7 @@ public class FramedLZ4CompressorOutputStreamTest {
@Test
public void testWriteByteArrayVsWriteByte() throws IOException {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
- final StringBuilder sb = new StringBuilder();
- sb.append("abcdefghijklmnop");
- final byte[] random = sb.toString().getBytes();
+ final byte[] random = "abcdefghijklmnop".getBytes();
try (FramedLZ4CompressorOutputStream compressor = new FramedLZ4CompressorOutputStream(buffer,
new FramedLZ4CompressorOutputStream.Parameters(FramedLZ4CompressorOutputStream.BlockSize.K64, true, false, false))) {
compressor.write(random);