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.junit.jupiter.api.Assertions;
20 import org.junit.jupiter.api.Test;
21 import org.orekit.errors.OrekitException;
22
23 import java.io.File;
24 import java.io.FileNotFoundException;
25 import java.net.URISyntaxException;
26 import java.util.regex.Pattern;
27
28 public class FilesListCrawlerTest extends AbstractListCrawlerTest<File> {
29
30 protected File input(String resource) {
31 try {
32 return new File(FilesListCrawlerTest.class.getClassLoader().getResource(resource).toURI().getPath());
33 } catch (URISyntaxException ue) {
34 Assertions.fail(ue.getLocalizedMessage());
35 return null;
36 }
37 }
38
39 protected FilesListCrawler build(String... inputs) {
40 File[] converted = new File[inputs.length];
41 for (int i = 0; i < inputs.length; ++i) {
42 converted[i] = input(inputs[i]);
43 }
44 return new FilesListCrawler(converted);
45 }
46
47 @Test
48 public void noElement() {
49 try {
50 File existing = new File(input("regular-data").getPath());
51 File inexistent = new File(existing.getParent(), "inexistant-directory");
52 new FilesListCrawler(inexistent).feed(Pattern.compile(".*"), new CountingLoader(),
53 DataContext.getDefault().getDataProvidersManager());
54 Assertions.fail("an exception should have been thrown");
55 } catch (OrekitException oe) {
56 Assertions.assertTrue(oe.getCause() instanceof FileNotFoundException);
57 Assertions.assertTrue(oe.getLocalizedMessage().contains("inexistant-directory"));
58 }
59 }
60
61 }