OSDN Git Service

test green: GerminGPX のログ形式に対応 debug
authorhayashi <hayashi.yuu@gmail.com>
Sun, 11 Jun 2017 03:05:33 +0000 (12:05 +0900)
committerhayashi <hayashi.yuu@gmail.com>
Sun, 11 Jun 2017 03:05:33 +0000 (12:05 +0900)
importPicture/AdjustTime.ini
importPicture/AdjustTime.ini.org
importPicture/src/osm/jp/gpx/ImportPicture.java
importPicture/test/osm/jp/gpx/ImportPictureTest.java

index f4e1829..63da9d7 100644 (file)
@@ -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
index 0f44ab2..ece77f6 100644 (file)
@@ -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
index 3dc7ef2..0b38001 100644 (file)
@@ -41,6 +41,11 @@ import org.w3c.dom.*;
 import org.xml.sax.SAXException;\r
 \r
 public class ImportPicture extends Thread {\r
+       /**\r
+        * 実行中に発生したExceptionを保持する場所\r
+        */\r
+       public Exception ex = null;\r
+       \r
     /**\r
      * ログ設定プロパティファイルのファイル内容\r
      */\r
@@ -107,6 +112,7 @@ public class ImportPicture extends Thread {
         Date jptime;\r
 \r
         ImportPicture obj = new ImportPicture();\r
+        obj.ex = null;\r
 \r
         if (argv.length > 0) {\r
             obj.imgDir = new File(argv[0]);\r
@@ -268,8 +274,11 @@ public class ImportPicture extends Thread {
         System.out.println(" - param: "+ AppParameters.GPX_OUTPUT_SPEED +"="+ Complementation.param_GpxOutputSpeed);\r
         obj.start();\r
         try {\r
-            obj.join();                            \r
+            obj.join();\r
         } catch(InterruptedException end) {}\r
+        if (obj.ex != null) {\r
+               throw obj.ex;\r
+        }\r
     }\r
     \r
     public File gpxDir;\r
@@ -320,6 +329,7 @@ public class ImportPicture extends Thread {
         }\r
         catch(ParserConfigurationException | DOMException | SAXException | IOException | ParseException | ImageReadException | ImageWriteException | IllegalArgumentException | TransformerException e) {\r
                e.printStackTrace();\r
+               this.ex = new Exception(e);\r
         }\r
     }\r
     \r
index b9543f3..3f7dfea 100644 (file)
@@ -18,6 +18,9 @@ import org.junit.Before;
 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 @@ public class ImportPictureTest {
                }
        }
 
+       @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 @@ public class ImportPictureTest {
                        // カメラディレクトリを作成する
                        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 @@ public class ImportPictureTest {
                        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 @@ public class ImportPictureTest {
                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 @@ public class ImportPictureTest {
                        }
                }
        }
-
+       
     /**
      * *.tar.gz解凍
      * ファイル更新日時をオリジナルと同じにします。