1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.data;
18
19
20 import java.io.File;
21 import java.io.InputStream;
22 import java.net.URISyntaxException;
23 import java.net.URL;
24 import java.util.regex.Pattern;
25
26 import org.hamcrest.CoreMatchers;
27 import org.hamcrest.MatcherAssert;
28 import org.junit.Assert;
29 import org.junit.Test;
30
31 public class ZipJarCrawlerTest {
32
33 @Test
34 public void testMultiZipClasspath() {
35 CountingLoader crawler = new CountingLoader();
36 new ZipJarCrawler("zipped-data/multizip.zip").feed(Pattern.compile(".*\\.txt$"), crawler,
37 DataContext.getDefault().getDataProvidersManager());
38 Assert.assertEquals(6, crawler.getCount());
39 }
40
41 @Test
42 public void testMultiZip() throws URISyntaxException {
43 URL url =
44 ZipJarCrawlerTest.class.getClassLoader().getResource("zipped-data/multizip.zip");
45 CountingLoader crawler = new CountingLoader();
46 new ZipJarCrawler(new File(url.toURI().getPath())).feed(Pattern.compile(".*\\.txt$"), crawler,
47 DataContext.getDefault().getDataProvidersManager());
48 Assert.assertEquals(6, crawler.getCount());
49 }
50
51 private static class CountingLoader implements DataLoader {
52 private int count = 0;
53 public boolean stillAcceptsData() {
54 return true;
55 }
56 public void loadData(InputStream input, String name) {
57 ++count;
58 MatcherAssert.assertThat(name, CoreMatchers.containsString("!/"));
59 }
60 public int getCount() {
61 return count;
62 }
63 }
64
65 }