3 import static org.hamcrest.CoreMatchers.is;
4 import static org.hamcrest.CoreMatchers.notNullValue;
5 import static org.junit.Assert.assertThat;
6 import static org.junit.Assert.fail;
8 import java.io.IOException;
9 import java.text.ParseException;
10 import java.util.Date;
11 import javax.xml.parsers.ParserConfigurationException;
12 import org.junit.experimental.theories.DataPoints;
13 import org.junit.experimental.theories.Theories;
14 import org.junit.experimental.theories.Theory;
15 import org.junit.runner.RunWith;
16 import org.w3c.dom.DOMException;
17 import org.xml.sax.SAXException;
19 public class ElementMapTRKSEGTest {
21 @RunWith(Theories.class)
22 public static class 各種GPXファイルを食わせる {
23 static class Fixture {
24 String gpxSourcePath; // GPXファイル(オリジナル)
25 int segCount; // GPXファイルに含まれるTRKSEGノードの数
27 public Fixture(String gpxSourcePath, int segCount) {
28 this.gpxSourcePath = gpxSourcePath;
29 this.segCount = segCount;
33 public String toString() {
34 String msg = "テストパターン : \n";
35 msg += "\tgpxSourcePath = "+ gpxSourcePath +"\n";
36 msg += "\tsegCount = "+ segCount;
42 public static Fixture[] datas = {
43 new Fixture("src/test/data/20170517.gpx", 1),
44 new Fixture("src/test/data/20170518.gpx", 1),
45 new Fixture("src/test/data/muiltiTRK.GarminColorado.gpx.xml", 3),
46 new Fixture("src/test/data/muiltiTRKSEG.GarminColorado.gpx.xml", 3),
47 new Fixture("src/test/data/muiltiTRKSEG.noNameSpace.gpx.xml", 3),
48 new Fixture("src/test/data/multiTRKSEG.eTrex_20J.gpx.xml", 3),
49 new Fixture("src/test/data/multiTRKSEGreverse.eTrex_20J.gpx.xml", 3),
53 public void TRKSEGを読み込む(Fixture dataset) {
55 ElementMapTRKSEG mapTRKSEG = new ElementMapTRKSEG();
56 mapTRKSEG.parse(new File(dataset.gpxSourcePath));
57 mapTRKSEG.printinfo();
58 System.out.println("GPX file: "+ dataset.gpxSourcePath);
59 assertThat(mapTRKSEG.size(), is(dataset.segCount));
60 for (Date key : mapTRKSEG.keySet()) {
61 assertThat(key, is(notNullValue()));
64 catch (IOException | ParseException | ParserConfigurationException | DOMException | SAXException e) {