params.store();
// 実行する
- 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が発生した。");
- }
+ 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");
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));
+ }
+
+ /**
+ * 実行する
+ * @throws Exception
+ */
+ public void testdo() {
try {
String[] argv = {
"./testdata/cameradata/10170518",
catch (Exception e) {
fail("Exceptionが発生した。");
}
+ }
+ }
- File file0 = new File("./testdata/output/10170518", "DSC05183.JPG");
+ 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();
+
+ // カメラディレクトリを作成する
+ TarGz.uncompress(new File("testdata", "WiMiUS20170518.tar.gz"), dir);
+
+ // 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);
+ }
+
+ 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();
+ }
+
+ @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/10170518", "DSC05184.JPG");
+ File file1 = new File("./testdata/output/cameradata", "20170518_094226A_snap.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");
+ File file3 = new File("./testdata/output/cameradata", "20170518_094737A.jpg");
assertThat(file3.exists(), is(true));
- File file4 = new File("./testdata/output/10170518", "DSC05205.JPG");
+ 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が発生した。");
+ }
+ }
}
-
}