OSDN Git Service

green: タイムスタンプのUTCとローカル時間との表示変換機能のテストを追加
[importpicture/importpicture.git] / importPicture / test / osm / jp / gpx / ImportPictureTest.java
index b9543f3..a2181fc 100644 (file)
@@ -14,382 +14,639 @@ import java.nio.channels.FileChannel;
 import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
 import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
 import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.commons.imaging.Imaging;
+import org.apache.commons.imaging.common.ImageMetadata;
+import org.apache.commons.imaging.formats.jpeg.JpegImageMetadata;
+import org.apache.commons.imaging.formats.tiff.TiffImageMetadata;
+import org.apache.commons.imaging.formats.tiff.constants.ExifTagConstants;
 import org.junit.runner.*;
-import org.junit.experimental.runners.Enclosed;
+import org.junit.experimental.theories.DataPoints;
+import org.junit.experimental.theories.Theories;
+import org.junit.experimental.theories.Theory;
 
-import hayashi.tools.files.DeleteDir;
-import osm.jp.gpx.utils.TarGz;
-
-@RunWith(Enclosed.class)
+@RunWith(Theories.class)
 public class ImportPictureTest {
-       
-       public static class SONYのカメラの場合 {
+       static class Expecter {
+               String value;
+               boolean expect;
+               String timeStr;
+               boolean magver;
                
-               @Before
-               public void setUp() throws Exception {
-                       // カメラディレクトリを削除する
-                       File dir = new File("testdata/cameradata");
-                       if (dir.exists()) {
-                               DeleteDir.delete(dir);
-                       }
-                       File outDir = new File("testdata/output");
-                       if (outDir.exists()) {
-                               DeleteDir.delete(outDir);
-                       }
-                       outDir.mkdir();
-                       
-                       // カメラディレクトリを作成する
-                       uncompress(new File("testdata", "Sony20170518.tar.gz"), dir);
-                       
-                       // GPXファイルをセット
-               try (   FileInputStream inStream = new FileInputStream(new File("testdata", "20170518.gpx"));
-                               FileOutputStream outStream = new FileOutputStream(new File("testdata/cameradata/10170518/20170518.gpx"));
-                       FileChannel inChannel = inStream.getChannel();
-                       FileChannel outChannel = outStream.getChannel();        )
-               {
-                   inChannel.transferTo(0, inChannel.size(), outChannel);
-               }
-               
-               // プロパティファイルを設定
-                       File iniFile = new File("AdjustTime.ini");
-                       File orgFile = new File("AdjustTime.ini.org");
-                       File testFile = new File("testdata", "AdjustTime.20170518.ini");
-                       if (orgFile.exists()) {
-                               orgFile.delete();
-                       }
-                       if (iniFile.exists()) {
-                               iniFile.renameTo(orgFile);
-                       }
-               try (   FileInputStream inStream = new FileInputStream(testFile);
-                               FileOutputStream outStream = new FileOutputStream(new File("AdjustTime.ini"));
-                               FileChannel inChannel = inStream.getChannel();
-                               FileChannel outChannel = outStream.getChannel();        )
-               {
-                   inChannel.transferTo(0, inChannel.size(),outChannel);
-               }
+               public Expecter(String value, boolean expect, String timeStr, boolean magver){
+                       this.value = value;
+                       this.expect = expect;
+                       this.timeStr = timeStr;
+                       this.magver = magver;
                }
+       }
 
-               @Test
-               public void FILE_UPDATE時間を基準にして時間外のファイルはコピー対象外の時() throws Exception {
-               // "AdjustTime.20170517.ini"のデフォルト状態で実行
-                       AppParameters params = new AppParameters();
-                       params.setProperty(AppParameters.GPX_BASETIME, "FILE_UPDATE");
-                       params.setProperty(AppParameters.IMG_OUTPUT_ALL, "false");
-                       params.store();
-               
-               // 実行する
-                       testdo();
-
-               File gpxfile = new File("./testdata/output/10170518", "20170518_.gpx");
-               assertThat(gpxfile.exists(), is(true));
-               File file0 = new File("./testdata/output/10170518", "DSC05183.JPG");
-               assertThat(file0.exists(), is(false));
-               File file1 = new File("./testdata/output/10170518", "DSC05184.JPG");
-               assertThat(file1.exists(), is(true));
-               File file2 = new File("./testdata/output/10170518", "DSC05196.JPG");
-               assertThat(file2.exists(), is(true));
-               File file3 = new File("./testdata/output/10170518", "DSC05204.JPG");
-               assertThat(file3.exists(), is(true));
-               File file4 = new File("./testdata/output/10170518", "DSC05205.JPG");
-               assertThat(file4.exists(), is(false));
-               }
+       static class Fixture {
+               String comment;                         // テスト概要(コメント)
+               String tarFilePath;                     // TARデータ
+               String gpxSourcePath;           // GPXファイル(オリジナル)
+               String gpxDestinationPath;      // GPXファイル(配置先)
+               String iniFilePath;                     // iniファイル
+               Expecter[] expecters;
                
-               @Test
-               public void FILE_UPDATE時間を基準にして時間外のファイルもコピーする時() throws Exception {
-                       AppParameters params = new AppParameters();
-                       params.setProperty(AppParameters.GPX_BASETIME, "FILE_UPDATE");
-                       params.setProperty(AppParameters.IMG_OUTPUT_ALL, "true");
-                       params.store();
-               
-               // 実行する
-                       testdo();
-
-               File gpxfile = new File("./testdata/output/10170518", "20170518_.gpx");
-               assertThat(gpxfile.exists(), is(true));
-               File file0 = new File("./testdata/output/10170518", "DSC05183.JPG");
-               assertThat(file0.exists(), is(true));
-               File file1 = new File("./testdata/output/10170518", "DSC05184.JPG");
-               assertThat(file1.exists(), is(true));
-               File file2 = new File("./testdata/output/10170518", "DSC05196.JPG");
-               assertThat(file2.exists(), is(true));
-               File file3 = new File("./testdata/output/10170518", "DSC05204.JPG");
-               assertThat(file3.exists(), is(true));
-               File file4 = new File("./testdata/output/10170518", "DSC05205.JPG");
-               assertThat(file4.exists(), is(true));
+               public Fixture(
+                               String comment,
+                               String tarFilePath,
+                               String gpxSourcePath,
+                               String gpxDestinationPath,
+                               String iniFilePath,
+                               Expecter[] expecters
+               ) {
+                       this.comment = comment;
+                       this.tarFilePath = tarFilePath;
+                       this.gpxSourcePath = gpxSourcePath;
+                       this.gpxDestinationPath = gpxDestinationPath;
+                       this.iniFilePath = iniFilePath;
+                       this.expecters = expecters;
                }
                
-               /**
-                * 実行する
-                * @throws Exception
-                */
-               public void testdo() {
-               try {
-                       String[] argv = {
-                                       "./testdata/cameradata/10170518",
-                                       "DSC05183.JPG",
-                                       "2017-05-18T09:16:48",
-                                       "./testdata/output",
-                                       "./testdata/cameradata/10170518"
-                       };
-                       ImportPicture.main(argv);
-                       }
-                       catch (Exception e) {
-                               fail("Exceptionが発生した。");
-                       }
+               public String toString() {
+                       String msg = "テストパターン : "+ comment + "\n";
+                       msg += "\ttarFilePath = "+ tarFilePath +"\n";
+                       msg += "\tgpxSourcePath = "+ gpxSourcePath +"\n";
+                       msg += "\tgpxDestinationPath = "+ gpxDestinationPath +"\n";
+                       msg += "\tiniFilePath = "+ iniFilePath;
+                       return msg;
                }
        }
 
-       public static class WiMiUSのカメラの場合 {
-               
-               @Before
-               public void setUp() throws Exception {
-                       // カメラディレクトリを削除する
-                       File dir = new File("testdata/cameradata");
-                       if (dir.exists()) {
-                               DeleteDir.delete(dir);
-                       }
-                       File outDir = new File("testdata/output");
-                       if (outDir.exists()) {
-                               DeleteDir.delete(outDir);
-                       }
-                       outDir.mkdir();
+       @DataPoints
+       public static Fixture[] datas = {
+                       new Fixture(
+                                       "[A1].SONYカメラの場合.FILE_UPDATE時間を基準にして時間外のファイルはコピー対象外の時",
+                                       "testdata/Sony20170518.tar.gz", 
+                                       "testdata/20170518.gpx",
+                                       "testdata/cameradata/20170518.gpx",
+                                       "testdata/AdjustTime.20170518.A1.ini",
+                                       new Expecter[] {
+                                               new Expecter("10170518/20170518_.gpx", true, null, true),
+                                               new Expecter("10170518/DSC05183.JPG", false, null, false),
+                                               new Expecter("10170518/DSC05184.JPG", true, "2017:05:18 00:34:44", true),
+                                               new Expecter("10170518/DSC05196.JPG", true, "2017:05:18 00:37:32", true),
+                                               new Expecter("10170518/DSC05204.JPG", true, "2017:05:18 00:46:48", true),
+                                               new Expecter("10170518/DSC05205.JPG", false, null, false),
+                                       }),
+                       new Fixture(
+                                       "[A2].SONYカメラの場合.FILE_UPDATE時間を基準にして時間外のファイルもコピーする時",
+                                       "testdata/Sony20170518.tar.gz", 
+                                       "testdata/20170518.gpx",
+                                       "testdata/cameradata/20170518.gpx",
+                                       "testdata/AdjustTime.20170518.A2.ini",
+                                       new Expecter[] {
+                                               new Expecter("10170518/20170518_.gpx", true, null, true),
+                                               new Expecter("10170518/DSC05183.JPG", true, "2017:05:18 00:16:48", true),
+                                               new Expecter("10170518/DSC05184.JPG", true, "2017:05:18 00:34:44", true),
+                                               new Expecter("10170518/DSC05196.JPG", true, "2017:05:18 00:37:32", true),
+                                               new Expecter("10170518/DSC05204.JPG", true, "2017:05:18 00:46:48", true),
+                                               new Expecter("10170518/DSC05205.JPG", true, "2017:05:18 00:48:04", true),
+                                       }),
                        
-                       // カメラディレクトリを作成する
-                       TarGz.uncompress(new File("testdata", "WiMiUS20170518.tar.gz"), dir);
+                       new Fixture(
+                                       "[B1].WiMiUSカメラの場合.FILE_UPDATE時間を基準にして時間外のファイルはコピー対象外の時",
+                                       "testdata/WiMiUS20170518.tar.gz", 
+                                       "testdata/20170518.gpx",
+                                       "testdata/cameradata/20170518.gpx",
+                                       "testdata/AdjustTime.20170518.B1.ini",
+                                       new Expecter[] {
+                                               new Expecter("cameradata/20170518_.gpx", true, null, true),
+                                               new Expecter("cameradata/20170518_092031A.jpg", false, null, false),
+                                               new Expecter("cameradata/20170518_094226A_snap.jpg", true, "2017:05:18 00:42:26", true),
+                                               new Expecter("cameradata/20170518_094737A.jpg", true, "2017:05:18 00:47:36", true),
+                                               new Expecter("cameradata/20170518_094827A.jpg", false, null, false),
+                                       }),
+
+                       new Fixture(
+                                       "[B2].WiMiUSカメラの場合.FILE_UPDATE時間を基準にして時間外のファイルもコピーする時",
+                                       "testdata/WiMiUS20170518.tar.gz", 
+                                       "testdata/20170518.gpx",
+                                       "testdata/cameradata/20170518.gpx",
+                                       "testdata/AdjustTime.20170518.B2.ini",
+                                       new Expecter[] {
+                                               new Expecter("cameradata/20170518_.gpx", true, null, true),
+                                               new Expecter("cameradata/20170518_092031A.jpg", true, "2017:05:18 00:20:30", true),
+                                               new Expecter("cameradata/20170518_094226A_snap.jpg", true, "2017:05:18 00:42:26", true),
+                                               new Expecter("cameradata/20170518_094737A.jpg", true, "2017:05:18 00:47:36", true),
+                                               new Expecter("cameradata/20170518_094827A.jpg", true, "2017:05:18 00:48:26", true),
+                                       }),
                        
-                       // GPXファイルをセット
-               try (   FileInputStream inStream = new FileInputStream(new File("testdata", "20170518.gpx"));
-                               FileOutputStream outStream = new FileOutputStream(new File("testdata/cameradata/20170518.gpx"));
-                       FileChannel inChannel = inStream.getChannel();
-                       FileChannel outChannel = outStream.getChannel();        )
-               {
-                   inChannel.transferTo(0, inChannel.size(), outChannel);
-               }
-               
-               // プロパティファイルを設定
-                       File iniFile = new File("AdjustTime.ini");
-                       File orgFile = new File("AdjustTime.ini.org");
-                       File testFile = new File("testdata", "AdjustTime.20170518.ini");
-                       if (orgFile.exists()) {
-                               orgFile.delete();
-                       }
-                       if (iniFile.exists()) {
-                               iniFile.renameTo(orgFile);
-                       }
-               try (   FileInputStream inStream = new FileInputStream(testFile);
-                               FileOutputStream outStream = new FileOutputStream(new File("AdjustTime.ini"));
-                               FileChannel inChannel = inStream.getChannel();
-                               FileChannel outChannel = outStream.getChannel();        )
-               {
-                   inChannel.transferTo(0, inChannel.size(),outChannel);
-               }
+                       new Fixture(
+                                       "[M1a].GPXが複数のTRKSEGに分割している場合.FILE_UPDATE時間を基準.GarminColorado",
+                                       "testdata/separate.tar.gz",
+                                       "testdata/muiltiTRK.GarminColorado.gpx.xml",
+                                       "testdata/cameradata/separate.gpx",
+                                       "testdata/AdjustTime.M1a.separate.ini",
+                                       new Expecter[] {
+                                       // GPX file
+                                               new Expecter("separate/separate_.gpx", true, null, true),
+                                   
+                                   // out of time ( - 2017-05-29T01:23:18)
+                                               new Expecter("separate/20170529_102305A.jpg", false, null, false),
+                                               new Expecter("separate/20170529_102314A.jpg", false, null, false),
+                                   
+                                   // in TRKSEG(1) (2017-05-29T01:23:18 - 2017-05-29T01:24:05)
+                                               new Expecter("separate/20170529_102318A.jpg", true, "2017:05:29 01:23:18",true),
+                                               new Expecter("separate/20170529_102322A.jpg", true, "2017:05:29 01:23:22",true),
+                                               new Expecter("separate/20170529_102405A.jpg", true, "2017:05:29 01:24:04",true),
 
-                       AppParameters params = new AppParameters();
-                       params.setProperty(AppParameters.IMG_TIME, "2017-05-18T09:20:30");
-                       params.setProperty(AppParameters.IMG_BASE_FILE, "20170518_092031A.jpg");
-                       params.setProperty(AppParameters.IMG_SOURCE_FOLDER, "./testdata/cameradata");
-                       params.setProperty(AppParameters.GPX_SOURCE_FOLDER, "./testdata/cameradata/20170518.gpx");
-                       params.store();
-               }
+                                   // out of time (2017-05-29T01:24:05 - 2017-05-29T01:24:37)
+                                               new Expecter("separate/20170529_102409A.jpg", false, null, false),
+                                               new Expecter("separate/20170529_102418A.jpg", false, null, false),
 
-               @Test
-               public void FILE_UPDATE時間を基準にして時間外のファイルはコピー対象外の時() throws Exception {
-                       AppParameters params = new AppParameters();
-                       params.setProperty(AppParameters.GPX_BASETIME, "FILE_UPDATE");
-                       params.setProperty(AppParameters.IMG_OUTPUT_ALL, "false");
-                       params.store();
-               
-               // 実行する
-                       testdo();
-
-               File gpxfile = new File("./testdata/output/cameradata", "20170518_.gpx");
-               assertThat(gpxfile.exists(), is(true));
-               File file0 = new File("./testdata/output/cameradata", "20170518_092031A.jpg");
-               assertThat(file0.exists(), is(false));
-               File file1 = new File("./testdata/output/cameradata", "20170518_094226A_snap.jpg");
-               assertThat(file1.exists(), is(true));
-               File file3 = new File("./testdata/output/cameradata", "20170518_094737A.jpg");
-               assertThat(file3.exists(), is(true));
-               File file4 = new File("./testdata/output/cameradata", "20170518_094827A.jpg");
-               assertThat(file4.exists(), is(false));
-               }
-               
-               @Test
-               public void FILE_UPDATE時間を基準にして時間外のファイルもコピーする時() throws Exception {
-                       AppParameters params = new AppParameters();
-                       params.setProperty(AppParameters.GPX_BASETIME, "FILE_UPDATE");
-                       params.setProperty(AppParameters.IMG_OUTPUT_ALL, "true");
-                       params.store();
-               
-               // 実行する
-                       testdo();
-
-               File gpxfile = new File("./testdata/output/cameradata", "20170518_.gpx");
-               assertThat(gpxfile.exists(), is(true));
-               File file0 = new File("./testdata/output/cameradata", "20170518_092031A.jpg");
-               assertThat(file0.exists(), is(true));
-               File file1 = new File("./testdata/output/cameradata", "20170518_094226A_snap.jpg");
-               assertThat(file1.exists(), is(true));
-               File file3 = new File("./testdata/output/cameradata", "20170518_094737A.jpg");
-               assertThat(file3.exists(), is(true));
-               File file4 = new File("./testdata/output/cameradata", "20170518_094827A.jpg");
-               assertThat(file4.exists(), is(true));
-               }
-               
-               /**
-                * 実行する
-                * @throws Exception
-                */
-               public void testdo() {
-               try {
-                       String[] argv = {
-                                       "./testdata/cameradata",
-                                       "20170518_092031A.jpg",
-                                       "2017-05-18T09:20:30",
-                                       "./testdata/output",
-                                       "./testdata/cameradata"
-                       };
-                       ImportPicture.main(argv);
-                       }
-                       catch (Exception e) {
-                               fail("Exceptionが発生した。");
-                       }
-               }
-       }
+                                   // in TRKSEG(2) (2017-05-29T01:24:37 - 2017-05-29T01:33:03)
+                                               new Expecter("separate/20170529_102448A.jpg", true, "2017:05:29 01:24:48",true),
+                                               new Expecter("separate/20170529_103246A.jpg", true, "2017:05:29 01:32:46",true),
+
+                                   // out of time (2017-05-29T01:33:03 - 2017-05-29T01:35:53)
+                                               new Expecter("separate/20170529_103315A.jpg", false, null, false),
+                                               new Expecter("separate/20170529_103545A.jpg", false, null, false),
+
+                                   // in TRKSEG(3) (2017-05-29T01:35:53 - 2017-05-29T01:47:35)
+                                               new Expecter("separate/20170529_103615A.jpg", true, "2017:05:29 01:36:14",true),
+                                               new Expecter("separate/20170529_104119A.jpg", true, "2017:05:29 01:41:18",true),
+                                       }),
+
+                       new Fixture(
+                                       "[M1b].GPXが複数のTRKSEGに分割している場合.FILE_UPDATE時間を基準.GarminColorado",
+                                       "testdata/separate.tar.gz", 
+                                       "testdata/muiltiTRK.GarminColorado.gpx.xml",
+                                       "testdata/cameradata/separate.gpx",
+                                       "testdata/AdjustTime.M1b.separate.ini",
+                                       new Expecter[] {
+                                               // GPX file
+                                                       new Expecter("separate/separate_.gpx", true, null, true),
+                                           
+                                           // out of time ( - 2017-05-29T01:23:18)
+                                                       new Expecter("separate/20170529_102305A.jpg", true, "2017:05:29 01:23:06", true),
+                                                       new Expecter("separate/20170529_102314A.jpg", true, "2017:05:29 01:23:14", true),
+                                           
+                                           // in TRKSEG(1) (2017-05-29T01:23:18 - 2017-05-29T01:24:05)
+                                                       new Expecter("separate/20170529_102318A.jpg", true, "2017:05:29 01:23:18",true),
+                                                       new Expecter("separate/20170529_102322A.jpg", true, "2017:05:29 01:23:22",true),
+                                                       new Expecter("separate/20170529_102405A.jpg", true, "2017:05:29 01:24:04",true),
+
+                                           // out of time (2017-05-29T01:24:05 - 2017-05-29T01:24:37)
+                                                       new Expecter("separate/20170529_102409A.jpg", true, "2017:05:29 01:24:10",true),
+                                                       new Expecter("separate/20170529_102418A.jpg", true, "2017:05:29 01:24:18",true),
+
+                                           // in TRKSEG(2) (2017-05-29T01:24:37 - 2017-05-29T01:33:03)
+                                                       new Expecter("separate/20170529_102448A.jpg", true, "2017:05:29 01:24:48",true),
+                                                       new Expecter("separate/20170529_103246A.jpg", true, "2017:05:29 01:32:46",true),
+
+                                           // out of time (2017-05-29T01:33:03 - 2017-05-29T01:35:53)
+                                                       new Expecter("separate/20170529_103315A.jpg", true, "2017:05:29 01:33:14",true),
+                                                       new Expecter("separate/20170529_103545A.jpg", true, "2017:05:29 01:35:44",true),
+
+                                           // in TRKSEG(3) (2017-05-29T01:35:53 - 2017-05-29T01:47:35)
+                                                       new Expecter("separate/20170529_103615A.jpg", true, "2017:05:29 01:36:14",true),
+                                                       new Expecter("separate/20170529_104119A.jpg", true, "2017:05:29 01:41:18",true),
+                                       }),
+
+                       new Fixture(
+                                       "[M1c].GPXが複数のTRKSEGに分割している場合.EXIF時間を基準.GarminColorado",
+                                       "testdata/separate.tar.gz", 
+                                       "testdata/muiltiTRK.GarminColorado.gpx.xml",
+                                       "testdata/cameradata/separate.gpx",
+                                       "testdata/AdjustTime.M1c.separate.ini",
+                                       new Expecter[] {
+                                               // GPX file
+                                                       new Expecter("separate/separate_.gpx", true, null, true),
+                                           
+                                           // out of time ( - 2017-05-29T01:23:18)
+                                                       new Expecter("separate/20170529_102305A.jpg", false, null, false),
+                                                       new Expecter("separate/20170529_102314A.jpg", false, null, false),
+                                           
+                                           // in TRKSEG(1) (2017-05-29T01:23:18 - 2017-05-29T01:24:05)
+                                                       new Expecter("separate/20170529_102318A.jpg", true, "2017:05:29 01:23:18",true),
+                                                       new Expecter("separate/20170529_102322A.jpg", true, "2017:05:29 01:23:22",true),
+                                                       new Expecter("separate/20170529_102405A.jpg", true, "2017:05:29 01:24:05",true),
+
+                                           // out of time (2017-05-29T01:24:05 - 2017-05-29T01:24:37)
+                                                       new Expecter("separate/20170529_102409A.jpg", false, null, false),
+                                                       new Expecter("separate/20170529_102418A.jpg", false, null, false),
+
+                                           // in TRKSEG(2) (2017-05-29T01:24:37 - 2017-05-29T01:33:03)
+                                                       new Expecter("separate/20170529_102448A.jpg", true, "2017:05:29 01:24:48",true),
+                                                       new Expecter("separate/20170529_103246A.jpg", true, "2017:05:29 01:32:46",true),
+
+                                           // out of time (2017-05-29T01:33:03 - 2017-05-29T01:35:53)
+                                                       new Expecter("separate/20170529_103315A.jpg", false, null, false),
+                                                       new Expecter("separate/20170529_103545A.jpg", false, null, false),
+
+                                           // in TRKSEG(3) (2017-05-29T01:35:53 - 2017-05-29T01:47:35)
+                                                       new Expecter("separate/20170529_103615A.jpg", true, "2017:05:29 01:36:14",true),
+                                                       new Expecter("separate/20170529_104119A.jpg", true, "2017:05:29 01:41:19",true),
+                                       }),
+
+                       new Fixture(
+                                       "[M1d].GPXが複数のTRKSEGに分割している場合.EXIF時間を基準.GarminColorado",
+                                       "testdata/separate.tar.gz", 
+                                       "testdata/muiltiTRK.GarminColorado.gpx.xml",
+                                       "testdata/cameradata/separate.gpx",
+                                       "testdata/AdjustTime.M1d.separate.ini",
+                                       new Expecter[] {
+                                               // GPX file
+                                                       new Expecter("separate/separate_.gpx", true, null, true),
+                                           
+                                           // out of time ( - 2017-05-29T01:23:18)
+                                                       new Expecter("separate/20170529_102305A.jpg", true, "2017:05:29 01:23:05", true),
+                                                       new Expecter("separate/20170529_102314A.jpg", true, "2017:05:29 01:23:14", true),
+                                           
+                                           // in TRKSEG(1) (2017-05-29T01:23:18 - 2017-05-29T01:24:05)
+                                                       new Expecter("separate/20170529_102318A.jpg", true, "2017:05:29 01:23:18",true),
+                                                       new Expecter("separate/20170529_102322A.jpg", true, "2017:05:29 01:23:22",true),
+                                                       new Expecter("separate/20170529_102405A.jpg", true, "2017:05:29 01:24:05",true),
+
+                                           // out of time (2017-05-29T01:24:05 - 2017-05-29T01:24:37)
+                                                       new Expecter("separate/20170529_102409A.jpg", true, "2017:05:29 01:24:09",true),
+                                                       new Expecter("separate/20170529_102418A.jpg", true, "2017:05:29 01:24:18",true),
+
+                                           // in TRKSEG(2) (2017-05-29T01:24:37 - 2017-05-29T01:33:03)
+                                                       new Expecter("separate/20170529_102448A.jpg", true, "2017:05:29 01:24:48",true),
+                                                       new Expecter("separate/20170529_103246A.jpg", true, "2017:05:29 01:32:46",true),
+
+                                           // out of time (2017-05-29T01:33:03 - 2017-05-29T01:35:53)
+                                                       new Expecter("separate/20170529_103315A.jpg", true, "2017:05:29 01:33:15",true),
+                                                       new Expecter("separate/20170529_103545A.jpg", true, "2017:05:29 01:35:45",true),
+
+                                           // in TRKSEG(3) (2017-05-29T01:35:53 - 2017-05-29T01:47:35)
+                                                       new Expecter("separate/20170529_103615A.jpg", true, "2017:05:29 01:36:14",true),
+                                                       new Expecter("separate/20170529_104119A.jpg", true, "2017:05:29 01:41:19",true),
+                                       }),
 
-       public static class GPXが複数のTRKSEGに分割している場合 {
-               
-               @Before
-               public void setUp() throws Exception {
-                       // カメラディレクトリを削除する
-                       File dir = new File("testdata/cameradata");
-                       if (dir.exists()) {
-                               DeleteDir.delete(dir);
-                       }
-                       File outDir = new File("testdata/output");
-                       if (outDir.exists()) {
-                               DeleteDir.delete(outDir);
-                       }
-                       outDir.mkdir();
                        
-                       // カメラディレクトリを作成する
-                       TarGz.uncompress(new File("testdata", "separate.tar.gz"), dir);
+                       new Fixture(
+                                       "[M2a].GPXが複数のTRKSEGに分割している場合.FILE_UPDATE時間を基準.eTrex_20J",
+                                       "testdata/separate.tar.gz", 
+                                       "testdata/multiTRKSEG.eTrex_20J.gpx.xml",
+                                       "testdata/cameradata/separate.gpx",
+                                       "testdata/AdjustTime.M2a.separate.ini",
+                                       new Expecter[] {
+                                               // GPX file
+                                                       new Expecter("separate/separate_.gpx", true, null, true),
+                                           
+                                           // out of time ( - 2017-05-29T01:23:18)
+                                                       new Expecter("separate/20170529_102305A.jpg", false, null, false),
+                                                       new Expecter("separate/20170529_102314A.jpg", false, null, false),
+                                           
+                                           // in TRKSEG(1) (2017-05-29T01:23:18 - 2017-05-29T01:24:05)
+                                                       new Expecter("separate/20170529_102318A.jpg", true, "2017:05:29 01:23:18",true),
+                                                       new Expecter("separate/20170529_102322A.jpg", true, "2017:05:29 01:23:22",true),
+                                                       new Expecter("separate/20170529_102405A.jpg", true, "2017:05:29 01:24:04",true),
+
+                                           // out of time (2017-05-29T01:24:05 - 2017-05-29T01:24:37)
+                                                       new Expecter("separate/20170529_102409A.jpg", false, null, false),
+                                                       new Expecter("separate/20170529_102418A.jpg", false, null, false),
+
+                                           // in TRKSEG(2) (2017-05-29T01:24:37 - 2017-05-29T01:33:03)
+                                                       new Expecter("separate/20170529_102448A.jpg", true, "2017:05:29 01:24:48",true),
+                                                       new Expecter("separate/20170529_103246A.jpg", true, "2017:05:29 01:32:46",true),
+
+                                           // out of time (2017-05-29T01:33:03 - 2017-05-29T01:35:53)
+                                                       new Expecter("separate/20170529_103315A.jpg", false, null, false),
+                                                       new Expecter("separate/20170529_103545A.jpg", false, null, false),
+
+                                           // in TRKSEG(3) (2017-05-29T01:35:53 - 2017-05-29T01:47:35)
+                                                       new Expecter("separate/20170529_103615A.jpg", true, "2017:05:29 01:36:14",true),
+                                                       new Expecter("separate/20170529_104119A.jpg", true, "2017:05:29 01:41:18",true),
+                                       }),
+
+                       new Fixture(
+                                       "[M2b].GPXが複数のTRKSEGに分割している場合.FILE_UPDATE時間を基準.eTrex_20J",
+                                       "testdata/separate.tar.gz", 
+                                       "testdata/multiTRKSEG.eTrex_20J.gpx.xml",
+                                       "testdata/cameradata/separate.gpx",
+                                       "testdata/AdjustTime.M2b.separate.ini",
+                                       new Expecter[] {
+                                               // GPX file
+                                                       new Expecter("separate/separate_.gpx", true, null, true),
+                                           
+                                           // out of time ( - 2017-05-29T01:23:18)
+                                                       new Expecter("separate/20170529_102305A.jpg", true, "2017:05:29 01:23:06", true),
+                                                       new Expecter("separate/20170529_102314A.jpg", true, "2017:05:29 01:23:14", true),
+                                           
+                                           // in TRKSEG(1) (2017-05-29T01:23:18 - 2017-05-29T01:24:05)
+                                                       new Expecter("separate/20170529_102318A.jpg", true, "2017:05:29 01:23:18",true),
+                                                       new Expecter("separate/20170529_102322A.jpg", true, "2017:05:29 01:23:22",true),
+                                                       new Expecter("separate/20170529_102405A.jpg", true, "2017:05:29 01:24:04",true),
+
+                                           // out of time (2017-05-29T01:24:05 - 2017-05-29T01:24:37)
+                                                       new Expecter("separate/20170529_102409A.jpg", true, "2017:05:29 01:24:10",true),
+                                                       new Expecter("separate/20170529_102418A.jpg", true, "2017:05:29 01:24:18",true),
+
+                                           // in TRKSEG(2) (2017-05-29T01:24:37 - 2017-05-29T01:33:03)
+                                                       new Expecter("separate/20170529_102448A.jpg", true, "2017:05:29 01:24:48",true),
+                                                       new Expecter("separate/20170529_103246A.jpg", true, "2017:05:29 01:32:46",true),
+
+                                           // out of time (2017-05-29T01:33:03 - 2017-05-29T01:35:53)
+                                                       new Expecter("separate/20170529_103315A.jpg", true, "2017:05:29 01:33:14",true),
+                                                       new Expecter("separate/20170529_103545A.jpg", true, "2017:05:29 01:35:44",true),
+
+                                           // in TRKSEG(3) (2017-05-29T01:35:53 - 2017-05-29T01:47:35)
+                                                       new Expecter("separate/20170529_103615A.jpg", true, "2017:05:29 01:36:14",true),
+                                                       new Expecter("separate/20170529_104119A.jpg", true, "2017:05:29 01:41:18",true),
+                                       }),
+
+                       new Fixture(
+                                       "[M2c].GPXが複数のTRKSEGに分割している場合.EXIF時間を基準.eTrex_20J",
+                                       "testdata/separate.tar.gz", 
+                                       "testdata/multiTRKSEG.eTrex_20J.gpx.xml",
+                                       "testdata/cameradata/separate.gpx",
+                                       "testdata/AdjustTime.M2c.separate.ini",
+                                       new Expecter[] {
+                                               // GPX file
+                                                       new Expecter("separate/separate_.gpx", true, null, true),
+                                           
+                                           // out of time ( - 2017-05-29T01:23:18)
+                                                       new Expecter("separate/20170529_102305A.jpg", false, null, false),
+                                                       new Expecter("separate/20170529_102314A.jpg", false, null, false),
+                                           
+                                           // in TRKSEG(1) (2017-05-29T01:23:18 - 2017-05-29T01:24:05)
+                                                       new Expecter("separate/20170529_102318A.jpg", true, "2017:05:29 01:23:18",true),
+                                                       new Expecter("separate/20170529_102322A.jpg", true, "2017:05:29 01:23:22",true),
+                                                       new Expecter("separate/20170529_102405A.jpg", true, "2017:05:29 01:24:05",true),
+
+                                           // out of time (2017-05-29T01:24:05 - 2017-05-29T01:24:37)
+                                                       new Expecter("separate/20170529_102409A.jpg", false, null, false),
+                                                       new Expecter("separate/20170529_102418A.jpg", false, null, false),
+
+                                           // in TRKSEG(2) (2017-05-29T01:24:37 - 2017-05-29T01:33:03)
+                                                       new Expecter("separate/20170529_102448A.jpg", true, "2017:05:29 01:24:48",true),
+                                                       new Expecter("separate/20170529_103246A.jpg", true, "2017:05:29 01:32:46",true),
+
+                                           // out of time (2017-05-29T01:33:03 - 2017-05-29T01:35:53)
+                                                       new Expecter("separate/20170529_103315A.jpg", false, null, false),
+                                                       new Expecter("separate/20170529_103545A.jpg", false, null, false),
+
+                                           // in TRKSEG(3) (2017-05-29T01:35:53 - 2017-05-29T01:47:35)
+                                                       new Expecter("separate/20170529_103615A.jpg", true, "2017:05:29 01:36:14",true),
+                                                       new Expecter("separate/20170529_104119A.jpg", true, "2017:05:29 01:41:19",true),
+                                       }),
+
+                       new Fixture(
+                                       "[M2d].GPXが複数のTRKSEGに分割している場合.EXIF時間を基準.eTrex_20J",
+                                       "testdata/separate.tar.gz", 
+                                       "testdata/multiTRKSEG.eTrex_20J.gpx.xml",
+                                       "testdata/cameradata/separate.gpx",
+                                       "testdata/AdjustTime.M2d.separate.ini",
+                                       new Expecter[] {
+                                               // GPX file
+                                                       new Expecter("separate/separate_.gpx", true, null, true),
+                                           
+                                           // out of time ( - 2017-05-29T01:23:18)
+                                                       new Expecter("separate/20170529_102305A.jpg", true, "2017:05:29 01:23:05", true),
+                                                       new Expecter("separate/20170529_102314A.jpg", true, "2017:05:29 01:23:14", true),
+                                           
+                                           // in TRKSEG(1) (2017-05-29T01:23:18 - 2017-05-29T01:24:05)
+                                                       new Expecter("separate/20170529_102318A.jpg", true, "2017:05:29 01:23:18",true),
+                                                       new Expecter("separate/20170529_102322A.jpg", true, "2017:05:29 01:23:22",true),
+                                                       new Expecter("separate/20170529_102405A.jpg", true, "2017:05:29 01:24:05",true),
+
+                                           // out of time (2017-05-29T01:24:05 - 2017-05-29T01:24:37)
+                                                       new Expecter("separate/20170529_102409A.jpg", true, "2017:05:29 01:24:09",true),
+                                                       new Expecter("separate/20170529_102418A.jpg", true, "2017:05:29 01:24:18",true),
+
+                                           // in TRKSEG(2) (2017-05-29T01:24:37 - 2017-05-29T01:33:03)
+                                                       new Expecter("separate/20170529_102448A.jpg", true, "2017:05:29 01:24:48",true),
+                                                       new Expecter("separate/20170529_103246A.jpg", true, "2017:05:29 01:32:46",true),
+
+                                           // out of time (2017-05-29T01:33:03 - 2017-05-29T01:35:53)
+                                                       new Expecter("separate/20170529_103315A.jpg", true, "2017:05:29 01:33:15",true),
+                                                       new Expecter("separate/20170529_103545A.jpg", true, "2017:05:29 01:35:45",true),
+
+                                           // in TRKSEG(3) (2017-05-29T01:35:53 - 2017-05-29T01:47:35)
+                                                       new Expecter("separate/20170529_103615A.jpg", true, "2017:05:29 01:36:14",true),
+                                                       new Expecter("separate/20170529_104119A.jpg", true, "2017:05:29 01:41:19",true),
+                                       }),
                        
-                       // GPXファイルをセット
-               try (   FileInputStream inStream = new FileInputStream(new File("testdata", "separate.gpx"));
-                               FileOutputStream outStream = new FileOutputStream(new File("testdata/cameradata/separate.gpx"));
-                       FileChannel inChannel = inStream.getChannel();
-                       FileChannel outChannel = outStream.getChannel();        )
-               {
-                   inChannel.transferTo(0, inChannel.size(), outChannel);
-               }
-               
-               // プロパティファイルを設定
-                       File iniFile = new File("AdjustTime.ini");
-                       File orgFile = new File("AdjustTime.ini.org");
-                       File testFile = new File("testdata", "AdjustTime.separate.ini");
-                       if (orgFile.exists()) {
-                               orgFile.delete();
-                       }
-                       if (iniFile.exists()) {
-                               iniFile.renameTo(orgFile);
-                       }
-               try (   FileInputStream inStream = new FileInputStream(testFile);
-                               FileOutputStream outStream = new FileOutputStream(new File("AdjustTime.ini"));
-                               FileChannel inChannel = inStream.getChannel();
-                               FileChannel outChannel = outStream.getChannel();        )
-               {
-                   inChannel.transferTo(0, inChannel.size(),outChannel);
-               }
+                       new Fixture(
+                                       "[M3a].GPXが複数のTRKSEGに分割している場合.FILE_UPDATE時間を基準.eTrex_20Jreverse",
+                                       "testdata/separate.tar.gz", 
+                                       "testdata/multiTRKSEGreverse.eTrex_20J.gpx.xml",
+                                       "testdata/cameradata/separate.gpx",
+                                       "testdata/AdjustTime.M2a.separate.ini",
+                                       new Expecter[] {
+                                               // GPX file
+                                                       new Expecter("separate/separate_.gpx", true, null, true),
+                                           
+                                           // out of time ( - 2017-05-29T01:23:18)
+                                                       new Expecter("separate/20170529_102305A.jpg", false, null, false),
+                                                       new Expecter("separate/20170529_102314A.jpg", false, null, false),
+                                           
+                                           // in TRKSEG(1) (2017-05-29T01:23:18 - 2017-05-29T01:24:05)
+                                                       new Expecter("separate/20170529_102318A.jpg", true, "2017:05:29 01:23:18",true),
+                                                       new Expecter("separate/20170529_102322A.jpg", true, "2017:05:29 01:23:22",true),
+                                                       new Expecter("separate/20170529_102405A.jpg", true, "2017:05:29 01:24:04",true),
 
-                       AppParameters params = new AppParameters();
-                       params.setProperty(AppParameters.IMG_TIME, "2017-05-29T10:31:46");
-                       params.setProperty(AppParameters.IMG_BASE_FILE, "20170529_103146A.jpg");
-                       params.setProperty(AppParameters.IMG_SOURCE_FOLDER, "./testdata/cameradata/separate");
-                       params.setProperty(AppParameters.GPX_SOURCE_FOLDER, "./testdata/cameradata/separate.gpx");
-                       params.store();
-               }
+                                           // out of time (2017-05-29T01:24:05 - 2017-05-29T01:24:37)
+                                                       new Expecter("separate/20170529_102409A.jpg", false, null, false),
+                                                       new Expecter("separate/20170529_102418A.jpg", false, null, false),
 
-               @Test
-               public void FILE_UPDATE時間を基準にして時間外のファイルはコピー対象外の時() throws Exception {
-                       AppParameters params = new AppParameters();
-                       params.setProperty(AppParameters.GPX_BASETIME, "FILE_UPDATE");
-                       params.setProperty(AppParameters.IMG_OUTPUT_ALL, "false");
-                       params.store();
-               
-               // 実行する
-                       testdo();
-
-                       boolean exists;
-               File gpxfile = new File("./testdata/output/separate", "separate_.gpx");
-               exists = gpxfile.exists();
-               assertThat(exists, is(true));
-               
-               File file0 = new File("./testdata/output/separate", "20170529_102305A.jpg");
-               exists = file0.exists();
-               assertThat(exists, is(false));
-               
-               File file1 = new File("./testdata/output/separate", "20170529_103146A.jpg");
-               exists = file1.exists();
-               assertThat(exists, is(true));
-
-               File file3 = new File("./testdata/output/separate", "20170529_103515A.jpg");
-               assertThat(file3.exists(), is(true));
-               exists = file3.exists();
-               assertThat(exists, is(true));
-
-               File file4 = new File("./testdata/output/separate", "20170529_104119A.jpg");
-               exists = file4.exists();
-               assertThat(exists, is(true));
-               }
+                                           // in TRKSEG(2) (2017-05-29T01:24:37 - 2017-05-29T01:33:03)
+                                                       new Expecter("separate/20170529_102448A.jpg", true, "2017:05:29 01:24:48",true),
+                                                       new Expecter("separate/20170529_103246A.jpg", true, "2017:05:29 01:32:46",true),
+
+                                           // out of time (2017-05-29T01:33:03 - 2017-05-29T01:35:53)
+                                                       new Expecter("separate/20170529_103315A.jpg", false, null, false),
+                                                       new Expecter("separate/20170529_103545A.jpg", false, null, false),
+
+                                           // in TRKSEG(3) (2017-05-29T01:35:53 - 2017-05-29T01:47:35)
+                                                       new Expecter("separate/20170529_103615A.jpg", true, "2017:05:29 01:36:14",true),
+                                                       new Expecter("separate/20170529_104119A.jpg", true, "2017:05:29 01:41:18",true),
+                                       }),
+
+                       new Fixture(
+                                       "[M3b].GPXが複数のTRKSEGに分割している場合.FILE_UPDATE時間を基準.eTrex_20Jreverse",
+                                       "testdata/separate.tar.gz", 
+                                       "testdata/multiTRKSEGreverse.eTrex_20J.gpx.xml",
+                                       "testdata/cameradata/separate.gpx",
+                                       "testdata/AdjustTime.M2b.separate.ini",
+                                       new Expecter[] {
+                                               // GPX file
+                                                       new Expecter("separate/separate_.gpx", true, null, true),
+
+                                           // out of time ( - 2017-05-29T01:23:18)
+                                                       new Expecter("separate/20170529_102305A.jpg", true, "2017:05:29 01:23:06", true),
+                                                       new Expecter("separate/20170529_102314A.jpg", true, "2017:05:29 01:23:14", true),
+                                           
+                                           // in TRKSEG(1) (2017-05-29T01:23:18 - 2017-05-29T01:24:05)
+                                                       new Expecter("separate/20170529_102318A.jpg", true, "2017:05:29 01:23:18",true),
+                                                       new Expecter("separate/20170529_102322A.jpg", true, "2017:05:29 01:23:22",true),
+                                                       new Expecter("separate/20170529_102405A.jpg", true, "2017:05:29 01:24:04",true),
+
+                                           // out of time (2017-05-29T01:24:05 - 2017-05-29T01:24:37)
+                                                       new Expecter("separate/20170529_102409A.jpg", true, "2017:05:29 01:24:10",true),
+                                                       new Expecter("separate/20170529_102418A.jpg", true, "2017:05:29 01:24:18",true),
+
+                                           // in TRKSEG(2) (2017-05-29T01:24:37 - 2017-05-29T01:33:03)
+                                                       new Expecter("separate/20170529_102448A.jpg", true, "2017:05:29 01:24:48",true),
+                                                       new Expecter("separate/20170529_103246A.jpg", true, "2017:05:29 01:32:46",true),
+
+                                           // out of time (2017-05-29T01:33:03 - 2017-05-29T01:35:53)
+                                                       new Expecter("separate/20170529_103315A.jpg", true, "2017:05:29 01:33:14",true),
+                                                       new Expecter("separate/20170529_103545A.jpg", true, "2017:05:29 01:35:44",true),
+
+                                           // in TRKSEG(3) (2017-05-29T01:35:53 - 2017-05-29T01:47:35)
+                                                       new Expecter("separate/20170529_103615A.jpg", true, "2017:05:29 01:36:14",true),
+                                                       new Expecter("separate/20170529_104119A.jpg", true, "2017:05:29 01:41:18",true),
+                                       }),
+
+                       new Fixture(
+                                       "[M3c].GPXが複数のTRKSEGに分割している場合.EXIF時間を基準.eTrex_20Jreverse",
+                                       "testdata/separate.tar.gz", 
+                                       "testdata/multiTRKSEGreverse.eTrex_20J.gpx.xml",
+                                       "testdata/cameradata/separate.gpx",
+                                       "testdata/AdjustTime.M2c.separate.ini",
+                                       new Expecter[] {
+                                               // GPX file
+                                                       new Expecter("separate/separate_.gpx", true, null, true),
+                                           
+                                           // out of time ( - 2017-05-29T01:23:18)
+                                                       new Expecter("separate/20170529_102305A.jpg", false, null, false),
+                                                       new Expecter("separate/20170529_102314A.jpg", false, null, false),
+                                           
+                                           // in TRKSEG(1) (2017-05-29T01:23:18 - 2017-05-29T01:24:05)
+                                                       new Expecter("separate/20170529_102318A.jpg", true, "2017:05:29 01:23:18",true),
+                                                       new Expecter("separate/20170529_102322A.jpg", true, "2017:05:29 01:23:22",true),
+                                                       new Expecter("separate/20170529_102405A.jpg", true, "2017:05:29 01:24:05",true),
+
+                                           // out of time (2017-05-29T01:24:05 - 2017-05-29T01:24:37)
+                                                       new Expecter("separate/20170529_102409A.jpg", false, null, false),
+                                                       new Expecter("separate/20170529_102418A.jpg", false, null, false),
+
+                                           // in TRKSEG(2) (2017-05-29T01:24:37 - 2017-05-29T01:33:03)
+                                                       new Expecter("separate/20170529_102448A.jpg", true, "2017:05:29 01:24:48",true),
+                                                       new Expecter("separate/20170529_103246A.jpg", true, "2017:05:29 01:32:46",true),
+
+                                           // out of time (2017-05-29T01:33:03 - 2017-05-29T01:35:53)
+                                                       new Expecter("separate/20170529_103315A.jpg", false, null, false),
+                                                       new Expecter("separate/20170529_103545A.jpg", false, null, false),
+
+                                           // in TRKSEG(3) (2017-05-29T01:35:53 - 2017-05-29T01:47:35)
+                                                       new Expecter("separate/20170529_103615A.jpg", true, "2017:05:29 01:36:14",true),
+                                                       new Expecter("separate/20170529_104119A.jpg", true, "2017:05:29 01:41:19",true),
+                                       }),
+
+                       new Fixture(
+                                       "[M3d].GPXが複数のTRKSEGに分割している場合.EXIF時間を基準.eTrex_20Jreverse",
+                                       "testdata/separate.tar.gz", 
+                                       "testdata/multiTRKSEGreverse.eTrex_20J.gpx.xml",
+                                       "testdata/cameradata/separate.gpx",
+                                       "testdata/AdjustTime.M2d.separate.ini",
+                                       new Expecter[] {
+                                               // GPX file
+                                                       new Expecter("separate/separate_.gpx", true, null, true),
+                                           
+                                           // out of time ( - 2017-05-29T01:23:18)
+                                                       new Expecter("separate/20170529_102305A.jpg", true, "2017:05:29 01:23:05", true),
+                                                       new Expecter("separate/20170529_102314A.jpg", true, "2017:05:29 01:23:14", true),
+                                           
+                                           // in TRKSEG(1) (2017-05-29T01:23:18 - 2017-05-29T01:24:05)
+                                                       new Expecter("separate/20170529_102318A.jpg", true, "2017:05:29 01:23:18",true),
+                                                       new Expecter("separate/20170529_102322A.jpg", true, "2017:05:29 01:23:22",true),
+                                                       new Expecter("separate/20170529_102405A.jpg", true, "2017:05:29 01:24:05",true),
+
+                                           // out of time (2017-05-29T01:24:05 - 2017-05-29T01:24:37)
+                                                       new Expecter("separate/20170529_102409A.jpg", true, "2017:05:29 01:24:09",true),
+                                                       new Expecter("separate/20170529_102418A.jpg", true, "2017:05:29 01:24:18",true),
 
-               @Test
-               public void EXIF時間を基準にして時間外のファイルはコピー対象外の時() throws Exception {
-                       AppParameters params = new AppParameters();
-                       params.setProperty(AppParameters.GPX_BASETIME, "EXIF_TIME");
-                       params.setProperty(AppParameters.IMG_OUTPUT_ALL, "false");
-                       params.store();
-               
-               // 実行する
-                       testdo();
-
-               File gpxfile = new File("./testdata/output/separate", "separate_.gpx");
-               assertThat(gpxfile.exists(), is(true));
-               File file0 = new File("./testdata/output/separate", "20170529_102305A.jpg");
-               assertThat(file0.exists(), is(false));
-               File file1 = new File("./testdata/output/separate", "20170529_103146A.jpg");
-               assertThat(file1.exists(), is(true));
-               File file3 = new File("./testdata/output/separate", "20170529_103515A.jpg");
-               assertThat(file3.exists(), is(true));
-               File file4 = new File("./testdata/output/separate", "20170529_104119A.jpg");
-               assertThat(file4.exists(), is(true));
+                                           // in TRKSEG(2) (2017-05-29T01:24:37 - 2017-05-29T01:33:03)
+                                                       new Expecter("separate/20170529_102448A.jpg", true, "2017:05:29 01:24:48",true),
+                                                       new Expecter("separate/20170529_103246A.jpg", true, "2017:05:29 01:32:46",true),
+
+                                           // out of time (2017-05-29T01:33:03 - 2017-05-29T01:35:53)
+                                                       new Expecter("separate/20170529_103315A.jpg", true, "2017:05:29 01:33:15",true),
+                                                       new Expecter("separate/20170529_103545A.jpg", true, "2017:05:29 01:35:45",true),
+
+                                           // in TRKSEG(3) (2017-05-29T01:35:53 - 2017-05-29T01:47:35)
+                                                       new Expecter("separate/20170529_103615A.jpg", true, "2017:05:29 01:36:14",true),
+                                                       new Expecter("separate/20170529_104119A.jpg", true, "2017:05:29 01:41:19",true),
+                                       }),
+       };
+
+
+       @Theory
+       public void パラメータテスト(Fixture dataset) throws Exception {
+               ImportPictureTest.setup(dataset);
+               ImportPictureTest.testdo(dataset.iniFilePath);
+               //SimpleDateFormat format = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss", Locale.UK);
+               
+               Expecter[] es = dataset.expecters;
+               AppParameters params = new AppParameters(dataset.iniFilePath);
+               File outDir = new File(params.getProperty(AppParameters.IMG_OUTPUT_FOLDER));
+               for (int i = 0; i < es.length; i++) {
+               File file = new File(outDir, es[i].value);
+               System.out.println("[JUnit.debug] assert file='"+ file.getAbsolutePath() +"'");
+               assertThat(file.exists(), is(es[i].expect));
+               if (es[i].timeStr != null) {
+                       // JPEG メタデータが存在すること
+                ImageMetadata meta = Imaging.getMetadata(file);
+                
+                // メタデータは インスタンスJpegImageMetadata であること
+               assertThat((meta instanceof JpegImageMetadata), is(true));
+                
+                JpegImageMetadata jpegMetadata = (JpegImageMetadata)meta;
+                assertNotNull(jpegMetadata);
+                
+                // EXIFデータが存在すること
+                TiffImageMetadata exif = jpegMetadata.getExif();
+                assertNotNull(exif);
+                
+                // EXIF-TIME が正しく設定されていること
+               String exifTime = ImportPicture.toEXIFString(ImportPicture.toEXIFDate(exif.getFieldValue(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL)[0]));
+               System.out.println("[debug] exifTime = '"+ exifTime +"' <--> '"+ es[i].timeStr +"'");
+               assertThat(exifTime, is(es[i].timeStr));
+               }
                }
+       }
+       
+       static void setup(Fixture dataset) throws IOException {
+               System.out.println(dataset.toString());
+               
+               // カメラディレクトリを削除する
+               File dir = new File("testdata/cameradata");
+               if (dir.exists()) {
+                       ImportPictureTest.delete(dir);
+               }
+               File outDir = new File("testdata/output");
+               if (outDir.exists()) {
+                       ImportPictureTest.delete(outDir);
+               }
+               outDir.mkdir();
+
+               // カメラディレクトリを作成する
+               ImportPictureTest.uncompress(new File(dataset.tarFilePath), new File("testdata/cameradata"));
                
-               /**
-                * 実行する
-                * @throws Exception
-                */
-               public void testdo() {
-               try {
-                       String[] argv = {
-                                       "./testdata/cameradata/separate",
-                                       "20170529_103146A.jpg",
-                                       "2017-05-29T10:31:46",
-                                       "./testdata/output",
-                                       "./testdata/cameradata/separate.gpx"
-                       };
-                       ImportPicture.main(argv);
-                       }
-                       catch (Exception e) {
-                               e.printStackTrace();
-                               fail("Exceptionが発生した。");
-                       }
+               // GPXファイルをセット
+        try (  FileInputStream inStream = new FileInputStream(new File(dataset.gpxSourcePath));
+                       FileOutputStream outStream = new FileOutputStream(new File(dataset.gpxDestinationPath));
+               FileChannel inChannel = inStream.getChannel();
+               FileChannel outChannel = outStream.getChannel();        )
+        {
+            inChannel.transferTo(0, inChannel.size(), outChannel);
+        }
+       }
+       
+       /**
+        * 実行する
+        * @throws Exception
+        */
+       static void testdo(String iniFilePath) {
+        try {
+               String[] argv = new String[1];
+               argv[0] = new String(iniFilePath);
+               ImportPicture.main(argv);
+               }
+               catch (Exception e) {
+                       e.printStackTrace();
+                       fail("Exceptionが発生した。");
                }
        }
 
-    /**
+       /**
      * *.tar.gz解凍
      * ファイル更新日時をオリジナルと同じにします。
      * @param tazFile 解凍する*.tar.gzファイル
@@ -405,7 +662,7 @@ public class ImportPictureTest {
         TarArchiveEntry tarEntry = tarIn.getNextTarEntry();
         while (tarEntry != null) {
             File destPath = new File(dest, tarEntry.getName());
-            System.out.println("uncompress: " + destPath.getCanonicalPath());
+            //System.out.println("uncompress: " + destPath.getCanonicalPath());
             if (tarEntry.isDirectory()) {
                 destPath.mkdirs();
             }
@@ -431,4 +688,24 @@ public class ImportPictureTest {
         }
         tarIn.close();
     }
+
+    public static void delete(File file) throws IOException {
+        if (!file.exists()) {
+            System.out.println("ERROR: ファイルまたはディレクトリが見つかりませんでした。");
+            throw new IOException("File not found.");
+        }
+        
+        if (file.isDirectory()) {
+            File files[] = file.listFiles();
+            if (files != null) {
+                for (int i=0; i < files.length; i++) {
+                    delete(files[i]);    // 再帰呼び出し
+                }
+            }
+        }
+        if (!file.delete()) {
+                       System.out.println("ERROR: ファイルは削除できませんでした。 '" + file.getAbsolutePath() +"'");
+        }
+        return;
+    }
 }