OSDN Git Service

fixed: maven test
[importpicture/importpicture.git] / src / test / java / osm / jp / gpx / ImportPictureTest.java
1 package osm.jp.gpx;
2
3 import static org.junit.Assert.*;
4
5 import java.io.File;
6 import java.io.FileInputStream;
7 import java.io.FileOutputStream;
8 import java.io.IOException;
9 import java.nio.channels.FileChannel;
10 import org.junit.runner.*;
11 import org.junit.experimental.theories.DataPoints;
12 import org.junit.experimental.theories.Theories;
13 import org.junit.experimental.theories.Theory;
14
15 @RunWith(Theories.class)
16 public class ImportPictureTest {
17
18     @DataPoints
19     public static Fixture[] datas = Fixture.datas;
20
21     @Theory
22     public void パラメータテスト(Fixture dataset) throws Exception {
23         setup(dataset);
24         testdo(dataset.iniFilePath);
25         Expecter.check(dataset);
26     }
27
28     void setup(Fixture dataset) throws IOException {
29         System.out.println(dataset.toString());
30
31         // カメラディレクトリを削除する
32         File dir = new File("target/test-classes/cameradata");
33         if (dir.exists()) {
34             UnZip.delete(dir);
35         }
36         File outDir = new File("target/test-classes/output");
37         if (outDir.exists()) {
38                 UnZip.delete(outDir);
39         }
40         outDir.mkdir();
41
42         // カメラディレクトリを作成する
43         UnZip.uncompress(new File(dataset.tarFilePath), new File("target/test-classes/cameradata"));
44
45         // GPXファイルをセット
46         try (FileInputStream inStream = new FileInputStream(new File(dataset.gpxSourcePath));
47             FileOutputStream outStream = new FileOutputStream(new File(dataset.gpxDestinationPath));
48             FileChannel inChannel = inStream.getChannel();
49             FileChannel outChannel = outStream.getChannel())
50         {
51             inChannel.transferTo(0, inChannel.size(), outChannel);
52         }
53     }
54
55     /**
56      * 実行する
57      * @throws Exception
58      */
59     void testdo(String iniFilePath) {
60         try {
61             String[] argv = {iniFilePath};
62             ImportPicture.main(argv);
63         }
64         catch (Exception e) {
65             e.printStackTrace();
66             fail("Exceptionが発生した。");
67         }
68     }
69 }