OSDN Git Service

4446e9d78ae93bdc3a2c9b72f1d58596915041bb
[importpicture/importpicture.git] / importPicture / test / osm / jp / gpx / ElementMapTRKSEGTest.java
1 package osm.jp.gpx;
2
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;
7
8 import java.io.File;
9 import java.util.Date;
10
11 import org.junit.experimental.theories.DataPoints;
12 import org.junit.experimental.theories.Theories;
13 import org.junit.experimental.theories.Theory;
14 import org.junit.runner.RunWith;
15
16 @RunWith(Theories.class)
17 public class ElementMapTRKSEGTest {
18
19         static class Fixture {
20                 String gpxSourcePath;           // GPXファイル(オリジナル)
21                 int segCount;                           // GPXファイルに含まれるTRKSEGノードの数
22                 
23                 public Fixture(
24                                 String gpxSourcePath,
25                                 int segCount
26                 ) {
27                         this.gpxSourcePath = gpxSourcePath;
28                         this.segCount = segCount;
29                 }
30                 
31                 public String toString() {
32                         String msg = "テストパターン : \n";
33                         msg += "\tgpxSourcePath = "+ gpxSourcePath +"\n";
34                         msg += "\tsegCount = "+ segCount;
35                         return msg;
36                 }
37         }
38
39         @DataPoints
40         public static Fixture[] datas = {
41                         new Fixture("testdata/20170517.gpx", 1),
42                         new Fixture("testdata/20170518.gpx", 1),
43                         new Fixture("testdata/muiltiTRK.GarminColorado.gpx.xml", 3),
44                         new Fixture("testdata/muiltiTRKSEG.GarminColorado.gpx.xml", 3),
45                         new Fixture("testdata/muiltiTRKSEG.noNameSpace.gpx.xml", 3),
46                         new Fixture("testdata/multiTRKSEG.eTrex_20J.gpx.xml", 3),
47                         new Fixture("testdata/multiTRKSEGreverse.eTrex_20J.gpx.xml", 3),
48         };
49
50         @Theory
51         public void TRKSEGを読み込む(Fixture dataset) {
52                 try {
53                 ElementMapTRKSEG mapTRKSEG = new ElementMapTRKSEG();
54                 mapTRKSEG.parse(new File(dataset.gpxSourcePath));
55                 mapTRKSEG.printinfo();
56                 System.out.println("GPX file: "+ dataset.gpxSourcePath);
57                         assertThat(mapTRKSEG.size(), is(dataset.segCount));
58                         for (Date key : mapTRKSEG.keySet()) {
59                                 assertThat(key, is(notNullValue()));
60                         }
61                 }
62                 catch (Exception e) {
63                         fail();
64                 }
65         }
66 }