()
| 31 | public class ZipUtilTest extends TestCase { |
| 32 | |
| 33 | public void testUnpackEntryFromFile() throws IOException { |
| 34 | final String name = "foo"; |
| 35 | final byte[] contents = "bar".getBytes(); |
| 36 | |
| 37 | File file = File.createTempFile("temp", null); |
| 38 | try { |
| 39 | // Create the ZIP file |
| 40 | ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(file)); |
| 41 | try { |
| 42 | zos.putNextEntry(new ZipEntry(name)); |
| 43 | zos.write(contents); |
| 44 | zos.closeEntry(); |
| 45 | } |
| 46 | finally { |
| 47 | IOUtils.closeQuietly(zos); |
| 48 | } |
| 49 | |
| 50 | // Test the ZipUtil |
| 51 | byte[] actual = ZipUtil.unpackEntry(file, name); |
| 52 | assertNotNull(actual); |
| 53 | assertEquals(new String(contents), new String(actual)); |
| 54 | } |
| 55 | // 1 |
| 56 | |
| 57 | // 2 |
| 58 | |
| 59 | // 3 |
| 60 | finally { |
| 61 | FileUtils.deleteQuietly(file); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | public void testUnpackEntryFromStream() throws IOException { |
| 66 | final String name = "foo"; |
nothing calls this directly
no outgoing calls
no test coverage detected