|
1 | 1 | package org.codehaus.plexus.archiver.zip;
|
2 | 2 |
|
3 | 3 | import java.io.File;
|
| 4 | +import java.io.IOException; |
4 | 5 | import java.lang.reflect.Method;
|
5 | 6 | import org.codehaus.plexus.PlexusTestCase;
|
| 7 | +import org.codehaus.plexus.archiver.Archiver; |
6 | 8 | import org.codehaus.plexus.archiver.UnArchiver;
|
7 | 9 | import org.codehaus.plexus.components.io.fileselectors.FileSelector;
|
8 | 10 | import org.codehaus.plexus.components.io.fileselectors.IncludeExcludeFileSelector;
|
@@ -69,6 +71,25 @@ public void testZeroFileModeInZip()
|
69 | 71 | {
|
70 | 72 | }
|
71 | 73 | }
|
| 74 | + |
| 75 | + public void testUnarchiveUtf8() |
| 76 | + throws Exception |
| 77 | + { |
| 78 | + File dest = new File("target/output/unzip/utf8"); |
| 79 | + dest.mkdirs(); |
| 80 | + |
| 81 | + final File zipFile = new File( "target/output/unzip/utf8-default.zip" ); |
| 82 | + final ZipArchiver zipArchiver = getZipArchiver( zipFile ); |
| 83 | + zipArchiver.addDirectory( new File( "src/test/resources/miscUtf8" ) ); |
| 84 | + zipArchiver.createArchive(); |
| 85 | + final ZipUnArchiver unarchiver = getZipUnArchiver(zipFile); |
| 86 | + unarchiver.setDestFile( dest ); |
| 87 | + unarchiver.extract(); |
| 88 | + assertTrue( new File( dest, "aPi\u00F1ata.txt" ).exists() ); |
| 89 | + assertTrue( new File( dest, "an\u00FCmlaut.txt").exists()); |
| 90 | + assertTrue( new File( dest, "\u20acuro.txt").exists()); |
| 91 | + } |
| 92 | + |
72 | 93 | private void runUnarchiver( String path, FileSelector[] selectors, boolean[] results )
|
73 | 94 | throws Exception
|
74 | 95 | {
|
@@ -124,4 +145,36 @@ public void testSelectors()
|
124 | 145 | fileSelector.setExcludes( new String[]{ "resources/artifactId/directory/test.properties" } );
|
125 | 146 | runUnarchiver( "", new FileSelector[]{ fileSelector }, new boolean[]{ true, false, false } );
|
126 | 147 | }
|
| 148 | + |
| 149 | + private ZipArchiver getZipArchiver() |
| 150 | + { |
| 151 | + try |
| 152 | + { |
| 153 | + return (ZipArchiver) lookup( Archiver.ROLE, "zip" ); |
| 154 | + } |
| 155 | + catch ( Exception e ) |
| 156 | + { |
| 157 | + throw new RuntimeException( e ); |
| 158 | + } |
| 159 | + } |
| 160 | + |
| 161 | + private ZipArchiver getZipUnArchiver() |
| 162 | + { |
| 163 | + try |
| 164 | + { |
| 165 | + return (ZipArchiver) lookup( UnArchiver.ROLE, "zip" ); |
| 166 | + } |
| 167 | + catch ( Exception e ) |
| 168 | + { |
| 169 | + throw new RuntimeException( e ); |
| 170 | + } |
| 171 | + } |
| 172 | + |
| 173 | + private ZipArchiver getZipArchiver( File destFile ) |
| 174 | + { |
| 175 | + final ZipArchiver zipArchiver = getZipArchiver(); |
| 176 | + zipArchiver.setDestFile( destFile ); |
| 177 | + return zipArchiver; |
| 178 | + } |
| 179 | + |
127 | 180 | }
|
0 commit comments