1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.orekit.models.earth.atmosphere.data;
20
21 import org.junit.jupiter.api.Assertions;
22 import org.junit.jupiter.api.BeforeEach;
23 import org.junit.jupiter.api.Test;
24 import org.orekit.Utils;
25 import org.orekit.data.DataSource;
26
27 import java.io.BufferedReader;
28 import java.io.IOException;
29 import java.io.InputStream;
30 import java.io.InputStreamReader;
31 import java.net.URISyntaxException;
32 import java.net.URL;
33 import java.nio.charset.StandardCharsets;
34 import java.nio.file.Paths;
35
36
37 public class CommonLineReaderTest {
38
39 @BeforeEach
40 public void setUp() {
41 Utils.setDataRoot("regular-data:atmosphere");
42 }
43
44 @Test
45 public void testParsing() throws IOException, URISyntaxException {
46 final String name = "DTCFILE_CommonLineReaderTest.txt";
47 URL url = CommonLineReaderTest.class.getClassLoader().getResource("atmosphere/"+name);
48 DataSource ds = new DataSource(Paths.get(url.toURI()).toString());
49
50 try (InputStream is = ds.getOpener().openStreamOnce();
51 InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8);
52 BufferedReader br = new BufferedReader(isr)) {
53
54 CommonLineReader reader = new CommonLineReader(br);
55 reader.readLine();
56 Assertions.assertTrue(reader.isEmptyLine());
57 reader.readLine();
58 Assertions.assertEquals(reader.getLine(), "DTC 2003 360 50 17 17 17 38 38 38 74 74 74 74 74 74 31 31 31 38 38 38 38 38 38 44 44");
59 Assertions.assertEquals(reader.getLineNumber(), 2);
60 Assertions.assertFalse(reader.isEmptyLine());
61
62 }
63 }
64
65 }