~ubuntu-branches/debian/stretch/libcommons-compress-java/stretch

« back to all changes in this revision

Viewing changes to src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg
  • Date: 2015-08-31 23:22:38 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20150831232238-gz3ynyvs68tok1a3
Tags: 1.10-1
* New upstream release
* Updated the OSGi metadata

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
package org.apache.commons.compress.archivers.zip;
20
20
 
 
21
import static org.junit.Assert.*;
 
22
 
21
23
import java.io.File;
22
24
import java.io.FileInputStream;
23
25
import java.io.IOException;
29
31
 
30
32
import org.apache.commons.compress.AbstractTestCase;
31
33
import org.apache.commons.compress.utils.CharsetNames;
 
34
import org.junit.Test;
32
35
 
33
36
public class UTF8ZipFilesTest extends AbstractTestCase {
34
37
 
37
40
    private static final String EURO_FOR_DOLLAR_TXT = "\u20AC_for_Dollar.txt";
38
41
    private static final String OIL_BARREL_TXT = "\u00D6lf\u00E4sser.txt";
39
42
 
 
43
    @Test
40
44
    public void testUtf8FileRoundtripExplicitUnicodeExtra()
41
45
        throws IOException {
42
46
        testFileRoundtrip(CharsetNames.UTF_8, true, true);
43
47
    }
44
48
 
 
49
    @Test
45
50
    public void testUtf8FileRoundtripNoEFSExplicitUnicodeExtra()
46
51
        throws IOException {
47
52
        testFileRoundtrip(CharsetNames.UTF_8, false, true);
48
53
    }
49
54
 
 
55
    @Test
50
56
    public void testCP437FileRoundtripExplicitUnicodeExtra()
51
57
        throws IOException {
52
58
        testFileRoundtrip(CP437, false, true);
53
59
    }
54
60
 
 
61
    @Test
55
62
    public void testASCIIFileRoundtripExplicitUnicodeExtra()
56
63
        throws IOException {
57
64
        testFileRoundtrip(CharsetNames.US_ASCII, false, true);
58
65
    }
59
66
 
 
67
    @Test
60
68
    public void testUtf8FileRoundtripImplicitUnicodeExtra()
61
69
        throws IOException {
62
70
        testFileRoundtrip(CharsetNames.UTF_8, true, false);
63
71
    }
64
72
 
 
73
    @Test
65
74
    public void testUtf8FileRoundtripNoEFSImplicitUnicodeExtra()
66
75
        throws IOException {
67
76
        testFileRoundtrip(CharsetNames.UTF_8, false, false);
68
77
    }
69
78
 
 
79
    @Test
70
80
    public void testCP437FileRoundtripImplicitUnicodeExtra()
71
81
        throws IOException {
72
82
        testFileRoundtrip(CP437, false, false);
73
83
    }
74
84
 
 
85
    @Test
75
86
    public void testASCIIFileRoundtripImplicitUnicodeExtra()
76
87
        throws IOException {
77
88
        testFileRoundtrip(CharsetNames.US_ASCII, false, false);
83
94
     * 7-ZIP doesn't use EFS for strings that can be encoded in CP437
84
95
     * - which is true for OIL_BARREL_TXT.
85
96
     */
 
97
    @Test
86
98
    public void testRead7ZipArchive() throws IOException {
87
99
        File archive = getFile("utf8-7zip-test.zip");
88
100
        ZipFile zf = null;
96
108
        }
97
109
    }
98
110
 
 
111
    @Test
99
112
    public void testRead7ZipArchiveForStream() throws IOException {
100
113
        FileInputStream archive =
101
114
            new FileInputStream(getFile("utf8-7zip-test.zip"));
116
129
     * WinZIP created archive, uses Unicode Extra Fields but only in
117
130
     * the central directory.
118
131
     */
 
132
    @Test
119
133
    public void testReadWinZipArchive() throws IOException {
120
134
        File archive = getFile("utf8-winzip-test.zip");
121
135
        ZipFile zf = null;
141
155
        }
142
156
    }
143
157
 
 
158
    @Test
144
159
    public void testReadWinZipArchiveForStream() throws IOException {
145
160
        FileInputStream archive =
146
161
            new FileInputStream(getFile("utf8-winzip-test.zip"));
157
172
        }
158
173
    }
159
174
 
 
175
    @Test
160
176
    public void testZipFileReadsUnicodeFields() throws IOException {
161
177
        File file = File.createTempFile("unicode-test", ".zip");
162
178
        file.deleteOnExit();
176
192
        }
177
193
    }
178
194
 
 
195
    @Test
179
196
    public void testZipArchiveInputStreamReadsUnicodeFields()
180
197
        throws IOException {
181
198
        File file = File.createTempFile("unicode-test", ".zip");
193
210
        }
194
211
    }
195
212
 
 
213
    @Test
196
214
    public void testRawNameReadFromZipFile()
197
215
        throws IOException {
198
216
        File archive = getFile("utf8-7zip-test.zip");
205
223
        }
206
224
    }
207
225
 
 
226
    @Test
208
227
    public void testRawNameReadFromStream()
209
228
        throws IOException {
210
229
        FileInputStream archive =
365
384
        }
366
385
    }
367
386
 
 
387
    @Test
368
388
    public void testUtf8Interoperability() throws IOException {
369
 
        File file1 = super.getFile("utf8-7zip-test.zip");
370
 
        File file2 = super.getFile("utf8-winzip-test.zip");
 
389
        File file1 = getFile("utf8-7zip-test.zip");
 
390
        File file2 = getFile("utf8-winzip-test.zip");
371
391
 
372
392
        testFile(file1,CP437);
373
393
        testFile(file2,CP437);