diff --git a/importPicture/AdjustTime.ini b/importPicture/AdjustTime.ini index f4e1829..63da9d7 100644 --- a/importPicture/AdjustTime.ini +++ b/importPicture/AdjustTime.ini @@ -1,5 +1,5 @@ #by AdjustTime -#Sun Jun 04 14:08:04 JST 2017 +#Sun Jun 11 12:00:43 JST 2017 GPX.BASETIME=FILE_UPDATE IMG.OUTPUT_EXIF=true GPX.OUTPUT_WPT=false diff --git a/importPicture/AdjustTime.ini.org b/importPicture/AdjustTime.ini.org index 0f44ab2..ece77f6 100644 --- a/importPicture/AdjustTime.ini.org +++ b/importPicture/AdjustTime.ini.org @@ -1,6 +1,6 @@ #by AdjustTime -#Sun Jun 04 14:07:56 JST 2017 -GPX.BASETIME=EXIF_TIME +#Sun Jun 11 12:00:31 JST 2017 +GPX.BASETIME=FILE_UPDATE IMG.OUTPUT_EXIF=true GPX.OUTPUT_WPT=false GPX.OUTPUT_SPEED=true diff --git a/importPicture/src/osm/jp/gpx/ImportPicture.java b/importPicture/src/osm/jp/gpx/ImportPicture.java index 3dc7ef2..0b38001 100644 --- a/importPicture/src/osm/jp/gpx/ImportPicture.java +++ b/importPicture/src/osm/jp/gpx/ImportPicture.java @@ -41,6 +41,11 @@ import org.xml.sax.SAXException; public class ImportPicture extends Thread { + /** + * 実行中に発生したExceptionを保持する場所 + */ + public Exception ex = null; + /** * ログ設定プロパティファイルのファイル内容 */ @@ -107,6 +112,7 @@ Date jptime; ImportPicture obj = new ImportPicture(); + obj.ex = null; if (argv.length > 0) { obj.imgDir = new File(argv[0]); @@ -268,8 +274,11 @@ System.out.println(" - param: "+ AppParameters.GPX_OUTPUT_SPEED +"="+ Complementation.param_GpxOutputSpeed); obj.start(); try { - obj.join(); + obj.join(); } catch(InterruptedException end) {} + if (obj.ex != null) { + throw obj.ex; + } } public File gpxDir; @@ -320,6 +329,7 @@ } catch(ParserConfigurationException | DOMException | SAXException | IOException | ParseException | ImageReadException | ImageWriteException | IllegalArgumentException | TransformerException e) { e.printStackTrace(); + this.ex = new Exception(e); } } diff --git a/importPicture/test/osm/jp/gpx/ImportPictureTest.java b/importPicture/test/osm/jp/gpx/ImportPictureTest.java index b9543f3..3f7dfea 100644 --- a/importPicture/test/osm/jp/gpx/ImportPictureTest.java +++ b/importPicture/test/osm/jp/gpx/ImportPictureTest.java @@ -18,6 +18,9 @@ import org.junit.Test; import org.junit.runner.*; import org.junit.experimental.runners.Enclosed; +import org.junit.experimental.theories.DataPoint; +import org.junit.experimental.theories.Theories; +import org.junit.experimental.theories.Theory; import hayashi.tools.files.DeleteDir; import osm.jp.gpx.utils.TarGz; @@ -259,7 +262,12 @@ } } + @RunWith(Theories.class) public static class GPXが複数のTRKSEGに分割している場合 { + @DataPoint + public static String GPX_MUILTI_TRK = new String("muiltiTRK.GarminColorado.gpx.xml"); + @DataPoint + public static String GPX_Muilti_TRKSEG = new String("multiTRKSEG.eTrex_20J.gpx.xml"); @Before public void setUp() throws Exception { @@ -277,14 +285,6 @@ // カメラディレクトリを作成する TarGz.uncompress(new File("testdata", "separate.tar.gz"), dir); - // 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"); @@ -312,15 +312,29 @@ params.store(); } - @Test - public void FILE_UPDATE時間を基準にして時間外のファイルはコピー対象外の時() throws Exception { + @Theory + public void FILE_UPDATE時間を基準にして時間外のファイルはコピー対象外の時(String gpxFileName) throws Exception { + // GPXファイルをセット + try ( FileInputStream inStream = new FileInputStream(new File("testdata", gpxFileName)); + FileOutputStream outStream = new FileOutputStream(new File("testdata/cameradata/separate.gpx")); + FileChannel inChannel = inStream.getChannel(); + FileChannel outChannel = outStream.getChannel(); ) + { + inChannel.transferTo(0, inChannel.size(), outChannel); + } + AppParameters params = new AppParameters(); params.setProperty(AppParameters.GPX_BASETIME, "FILE_UPDATE"); params.setProperty(AppParameters.IMG_OUTPUT_ALL, "false"); params.store(); // 実行する - testdo(); + try { + testdo(); + } + catch (Exception e) { + fail(); + } boolean exists; File gpxfile = new File("./testdata/output/separate", "separate_.gpx"); @@ -345,15 +359,29 @@ assertThat(exists, is(true)); } - @Test - public void EXIF時間を基準にして時間外のファイルはコピー対象外の時() throws Exception { + @Theory + public void EXIF時間を基準にして時間外のファイルはコピー対象外の時(String gpxFileName) throws Exception { + // GPXファイルをセット + try ( FileInputStream inStream = new FileInputStream(new File("testdata", gpxFileName)); + FileOutputStream outStream = new FileOutputStream(new File("testdata/cameradata/separate.gpx")); + FileChannel inChannel = inStream.getChannel(); + FileChannel outChannel = outStream.getChannel(); ) + { + inChannel.transferTo(0, inChannel.size(), outChannel); + } + AppParameters params = new AppParameters(); params.setProperty(AppParameters.GPX_BASETIME, "EXIF_TIME"); params.setProperty(AppParameters.IMG_OUTPUT_ALL, "false"); params.store(); // 実行する - testdo(); + try { + testdo(); + } + catch (Exception e) { + fail(); + } File gpxfile = new File("./testdata/output/separate", "separate_.gpx"); assertThat(gpxfile.exists(), is(true)); @@ -388,7 +416,7 @@ } } } - + /** * *.tar.gz解凍 * ファイル更新日時をオリジナルと同じにします。