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/01/16 13:44:02 UTC

[commons-compress] branch master updated (fc821091 -> 2a1ab490)

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 fc821091 Camel case local names
     new af158789 Format tweak
     new 2a1ab490 Add disabled test for COMPRESS-638

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:
 .../gzip/GzipCompressorOutputStream.java           |  2 +-
 .../gzip/GzipCompressorOutputStreamTest.java       | 69 ++++++++++++++++++++++
 2 files changed, 70 insertions(+), 1 deletion(-)
 create mode 100644 src/test/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStreamTest.java


[commons-compress] 02/02: Add disabled test for COMPRESS-638

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 2a1ab49057b6071e302a64be362397d4dd76f215
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Jan 16 08:43:57 2023 -0500

    Add disabled test for COMPRESS-638
---
 .../gzip/GzipCompressorOutputStreamTest.java       | 69 ++++++++++++++++++++++
 1 file changed, 69 insertions(+)

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
new file mode 100644
index 00000000..70bd8833
--- /dev/null
+++ b/src/test/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStreamTest.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.compress.compressors.gzip;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests {@link GzipCompressorOutputStream}.
+ */
+public class GzipCompressorOutputStreamTest {
+
+    private void testFileName(final String sourceFile) throws IOException {
+        final Path tempSourceFile = Files.createTempFile(sourceFile, sourceFile);
+        Files.write(tempSourceFile, "<text>Hello World!</text>".getBytes(StandardCharsets.ISO_8859_1));
+        final Path targetFile = Files.createTempFile("test", ".gz");
+        final GzipParameters parameters = new GzipParameters();
+        parameters.setFilename(sourceFile);
+        try (OutputStream fos = Files.newOutputStream(targetFile); GzipCompressorOutputStream gos = new GzipCompressorOutputStream(fos, parameters)) {
+            Files.copy(tempSourceFile, gos);
+        }
+        try (GzipCompressorInputStream gis = new GzipCompressorInputStream(Files.newInputStream(targetFile))) {
+            assertEquals(sourceFile, gis.getMetaData().getFilename());
+        }
+    }
+
+    @Test
+    public void testFileNameAscii() throws IOException {
+        testFileName("ASCII.xml");
+    }
+
+    /**
+     * Tests COMPRESS-638.
+     *
+     * @throws IOException When the test fails.
+     */
+    @Test
+    @Disabled("COMPRESS-638")
+    public void testFileNameChinese() throws IOException {
+        // "Test Chinese name"
+        testFileName("\u6D4B\u8BD5\u4E2D\u6587\u540D\u79F0.xml");
+    }
+
+}


[commons-compress] 01/02: Format tweak

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 af158789a24088dce5d89a6788fa72c9e3996c6f
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Jan 16 08:27:59 2023 -0500

    Format tweak
---
 .../commons/compress/compressors/gzip/GzipCompressorOutputStream.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java
index 604398bb..e9d259dd 100644
--- a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java
@@ -166,7 +166,7 @@ public class GzipCompressorOutputStream extends CompressorOutputStream {
 
     @Override
     public void write(final int b) throws IOException {
-        write(new byte[]{(byte) (b & 0xff)}, 0, 1);
+        write(new byte[] { (byte) (b & 0xff) }, 0, 1);
     }
 
     private void writeHeader(final GzipParameters parameters) throws IOException {