1   /* Copyright 2002-2025 CS GROUP
2    * Licensed to CS GROUP (CS) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * CS licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
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  }