• R/O
  • HTTP
  • SSH
  • HTTPS

importpicture: Commit


Commit MetaInfo

Revision1c4f1496653d5b00bd235b2dcd95a37a0a0c44e2 (tree)
Time2019-11-24 10:54:11
Authorhaya4 <hayashi.yuu@gmai...>
Commiterhaya4

Log Message

ver 3.1.3
fixed

Change Summary

Incremental Difference

--- a/src/test/java/osm/jp/gpx/RestampTest.java
+++ b/src/test/java/osm/jp/gpx/RestampTest.java
@@ -1,11 +1,17 @@
11 package osm.jp.gpx;
22
3+import java.io.File;
4+import java.text.DateFormat;
5+import java.text.SimpleDateFormat;
6+import java.util.Date;
7+import static org.hamcrest.CoreMatchers.is;
38 import org.junit.After;
49 import org.junit.AfterClass;
510 import org.junit.Before;
611 import org.junit.BeforeClass;
712 import org.junit.Test;
813 import static org.junit.Assert.*;
14+import static osm.jp.gpx.Restamp.TIME_PATTERN;
915
1016 /**
1117 *
@@ -26,31 +32,133 @@ public class RestampTest {
2632
2733 @Before
2834 public void setUp() {
35+ dirPath = "./src/test/data/images";
2936 }
3037
3138 @After
3239 public void tearDown() {
3340 }
3441
35- /**
36- * Test of main method, of class Restamp.
37- */
42+ String dirPath;
43+
3844 @Test
3945 public void testMain() {
46+ String[] ans = {
47+ "2019-09-01 16:26:51 JST",
48+ "2019-09-01 16:26:56 JST",
49+ "2019-09-01 16:27:01 JST",
50+ "2019-09-01 16:27:06 JST",
51+ "2019-09-01 16:27:11 JST",
52+ };
53+
54+ try {
55+ String[] argv = new String[]{
56+ dirPath,
57+ "00001.jpg",
58+ "2019-09-01 16:26:51 JST",
59+ "00003.jpg",
60+ "2019-09-01 16:27:01 JST"
61+ };
62+ Restamp.main(argv);
63+ check(new File(dirPath), ans);
64+ }
65+ catch (Exception e) {
66+ fail();
67+ }
68+ }
69+
70+ @Test
71+ public void testMain_2() {
72+ String[] ans = {
73+ "2019-09-02 16:26:53 JST",
74+ "2019-09-02 16:26:56 JST",
75+ "2019-09-02 16:26:58 JST",
76+ "2019-09-02 16:27:01 JST",
77+ "2019-09-02 16:27:03 JST",
78+ };
79+
80+ try {
81+ String[] argv = new String[]{
82+ dirPath,
83+ "00002.jpg",
84+ "2019-09-02 16:26:56 JST",
85+ "00004.jpg",
86+ "2019-09-02 16:27:01 JST"
87+ };
88+ Restamp.main(argv);
89+ check(new File(dirPath), ans);
90+ }
91+ catch (Exception e) {
92+ fail();
93+ }
94+ }
95+
96+ @Test
97+ public void testMain_3() {
98+ String[] ans = {
99+ "2019-09-03 16:26:53 JST",
100+ "2019-09-03 16:26:55 JST",
101+ "2019-09-03 16:26:58 JST",
102+ "2019-09-03 16:27:00 JST",
103+ "2019-09-03 16:27:03 JST",
104+ };
105+
40106 try {
41- System.out.println("main");
42107 String[] argv = new String[]{
43- "/home/yuu/Desktop/OSM/20180325_横浜新道/img",
44- "000033.jpg",
45- "2018-03-25_12:20:32",
46- "003752.jpg",
47- "2018-03-25_13:22:42"
108+ dirPath,
109+ "00001.jpg",
110+ "2019-09-03 16:26:53 JST",
111+ "00003.jpg",
112+ "2019-09-03 16:26:58 JST"
48113 };
49114 Restamp.main(argv);
115+ check(new File(dirPath), ans);
50116 }
51117 catch (Exception e) {
52118 fail();
53119 }
54120 }
121+
122+ @Test
123+ public void testMain_4() {
124+ String[] ans = {
125+ "2019-09-04 16:26:53 JST",
126+ "2019-09-04 16:26:55 JST",
127+ "2019-09-04 16:26:58 JST",
128+ "2019-09-04 16:27:00 JST",
129+ "2019-09-04 16:27:03 JST",
130+ };
131+
132+ try {
133+ String[] argv = new String[]{
134+ dirPath,
135+ "00003.jpg",
136+ "2019-09-04 16:26:58 JST",
137+ "00005.jpg",
138+ "2019-09-04 16:27:03 JST"
139+ };
140+ Restamp.main(argv);
141+ check(new File(dirPath), ans);
142+ }
143+ catch (Exception e) {
144+ fail();
145+ }
146+ }
147+
148+ void check(File imgDir, String[] ans) {
149+ DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
150+
151+ File[] files = imgDir.listFiles();
152+ java.util.Arrays.sort(files, (File file1, File file2) -> file1.getName().compareTo(file2.getName()));
153+
154+ int i = 0;
155+ for (File jpgFile : files) {
156+ long msec = jpgFile.lastModified();
157+ String lastModifiedStr = df.format(new Date(msec));
158+ assertThat(lastModifiedStr, is(ans[i]));
159+ i++;
160+ }
161+
162+ }
55163
56164 }
Show on old repository browser