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