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