3 import static org.hamcrest.CoreMatchers.is;
4 import static org.junit.Assert.*;
8 import org.junit.runner.*;
9 import org.junit.Before;
10 import org.junit.Test;
11 import org.junit.experimental.runners.*;
13 @RunWith(Enclosed.class)
14 public class ImportPictureUnitTest {
16 public static class 出力ディレクトリが存在しないとき {
19 public void setUp() throws Exception {
20 Fixture dataset = Fixture.datas[0];
21 System.out.println(dataset.toString());
24 File dir = new File("target/test-classes/cameradata");
28 File outDir = new File("target/test-classes/output");
29 if (outDir.exists()) {
35 UnZip.uncompress(new File(dataset.tarFilePath), new File("target/test-classes/cameradata"));
40 public void 実行() throws Exception {
41 Fixture dataset = Fixture.datas[0];
43 ImportPictureUnitTest.testdo(dataset.iniFilePath);
47 fail("Exceptionが発生した。");
50 AppParameters params = new AppParameters(dataset.iniFilePath);
51 File outDir = new File(params.getProperty(AppParameters.IMG_OUTPUT_FOLDER));
52 assertThat(outDir.exists(), is(true));
54 Expecter.check(dataset);
58 public void MAGVARをON() throws Exception {
59 Fixture dataset = Fixture.datas[1];
61 ImportPictureUnitTest.testdo(dataset.iniFilePath);
65 fail("Exceptionが発生した。");
68 AppParameters params = new AppParameters(dataset.iniFilePath);
69 File outDir = new File(params.getProperty(AppParameters.IMG_OUTPUT_FOLDER));
70 assertThat(outDir.exists(), is(true));
72 Expecter.check(dataset);
75 static String comparePosition(double b) {
76 return String.format("%.4f", b);
80 public static class 出力ディレクトリがFILEのとき {
83 public void setUp() throws Exception {
84 Fixture dataset = Fixture.datas[0];
85 System.out.println(dataset.toString());
88 File dir = new File("target/test-classes/cameradata");
92 File outDir = new File("target/test-classes/output");
93 if (outDir.exists()) {
98 outDir.createNewFile();
101 UnZip.uncompress(new File(dataset.tarFilePath), new File("target/test-classes/cameradata"));
106 public void 実行() throws Exception {
107 Fixture dataset = Fixture.datas[0];
109 ImportPictureUnitTest.testdo(dataset.iniFilePath);
110 fail("outDirがFILEなのに、例外が発生しなかった"); // 例外が発生しなかった
112 catch (Exception e) {
114 assertThat(true, is(true));
117 AppParameters params = new AppParameters(dataset.iniFilePath);
118 File outDir = new File(params.getProperty(AppParameters.IMG_OUTPUT_FOLDER));
119 assertThat(outDir.exists(), is(true));
122 static String comparePosition(double b) {
123 return String.format("%.4f", b);
132 static void testdo(String iniFilePath) throws Exception {
133 String[] argv = {iniFilePath};
134 ImportPicture.main(argv);