1 | package org.armedbear.lisp; |
---|
2 | |
---|
3 | import java.io.FileNotFoundException; |
---|
4 | import static org.junit.Assert.*; |
---|
5 | |
---|
6 | import java.io.File; |
---|
7 | import java.io.FileInputStream; |
---|
8 | import java.io.FileWriter; |
---|
9 | import org.junit.Test; |
---|
10 | import java.io.IOException; |
---|
11 | import java.io.InputStream; |
---|
12 | import java.util.jar.JarFile; |
---|
13 | import java.util.jar.JarInputStream; |
---|
14 | import java.util.zip.ZipEntry; |
---|
15 | import java.util.zip.ZipInputStream; |
---|
16 | import org.junit.Before; |
---|
17 | |
---|
18 | public class UtilitiesTest |
---|
19 | { |
---|
20 | File zipFile; |
---|
21 | |
---|
22 | |
---|
23 | @Before |
---|
24 | public void setup() { |
---|
25 | // XXX currently created by the ABCL Lisp based tests |
---|
26 | zipFile = new File("test/lisp/abcl/baz.jar"); |
---|
27 | assertTrue(zipFile.canRead()); |
---|
28 | } |
---|
29 | |
---|
30 | |
---|
31 | @Test |
---|
32 | public void getZipEntry() throws FileNotFoundException, IOException { |
---|
33 | FileInputStream inputFile = new FileInputStream(zipFile); |
---|
34 | ZipInputStream input = new ZipInputStream(inputFile); |
---|
35 | ZipEntry entry = Utilities.getEntry(input, "a/b/bar.abcl"); |
---|
36 | assertNotNull(entry); |
---|
37 | input.close(); |
---|
38 | inputFile.close(); |
---|
39 | } |
---|
40 | |
---|
41 | @Test |
---|
42 | public void getZipInputStreamZipEntry() throws FileNotFoundException, IOException { |
---|
43 | JarFile jar = new JarFile(zipFile); |
---|
44 | Pathname pathname = new Pathname("a/b/bar.abcl"); |
---|
45 | InputStream entryInputStream = Utilities.getInputStream(jar, pathname); |
---|
46 | assertNotNull(entryInputStream); |
---|
47 | ZipInputStream zip = new ZipInputStream(entryInputStream); |
---|
48 | assertNotNull(zip); |
---|
49 | ZipEntry entry = Utilities.getEntry(zip, "bar._"); |
---|
50 | assertNotNull(entry); |
---|
51 | } |
---|
52 | |
---|
53 | } |
---|