diff --git a/pom.xml b/pom.xml
index 11d281e..446da37 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,12 +2,11 @@
4.0.0
osm.surveyor
AdjustTime
- 5.3
+ 5.3-SNAPSHOT
scm:git:http://surveyor.mydns.jp/gitbucket/git/yuu/AdjustTime.git
http://surveyor.mydns.jp/gitbucket/yuu/AdjustTime/wiki
scm:git:http://surveyor.mydns.jp/gitbucket/git/yuu/AdjustTime.git
- v5.3
@@ -44,7 +43,7 @@
org.hamcrest
hamcrest-core
- 1.3
+ 2.2
test
jar
diff --git a/src/test/java/osm/jp/gpx/AppParametersTest.java b/src/test/java/osm/jp/gpx/AppParametersTest.java
index 9e422f1..3b3959c 100644
--- a/src/test/java/osm/jp/gpx/AppParametersTest.java
+++ b/src/test/java/osm/jp/gpx/AppParametersTest.java
@@ -1,6 +1,5 @@
package osm.jp.gpx;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
import java.io.File;
@@ -22,27 +21,12 @@
@Before
public void setUp() throws Exception {
- File iniFile = new File("AdjustTime.ini");
- File orgFile = new File("AdjustTime.ini.org");
-
- if (orgFile.exists()) {
- orgFile.delete();
- }
- if (iniFile.exists()) {
- iniFile.renameTo(orgFile);
- }
+ delTestData("AdjustTime.ini");
}
@After
public void tearDown() throws Exception {
- File iniFile = new File("AdjustTime.ini");
- File orgFile = new File("AdjustTime.ini.org");
- if (iniFile.exists()) {
- iniFile.delete();
- }
- if (orgFile.exists()) {
- orgFile.renameTo(iniFile);
- }
+ delTestData("AdjustTime.ini");
}
@Test
@@ -50,7 +34,7 @@
try {
AppParameters params = new AppParameters("target/test-classes/AdjustTime.off.ini");
String valueStr = params.getProperty(AppParameters.IMG_OUTPUT_ALL);
- assertThat(valueStr, is("false"));
+ assertFalse(Boolean.getBoolean(valueStr));
}
catch (IOException e) {
fail("Exceptionが発生した。");
@@ -62,42 +46,13 @@
@Before
public void setUp() throws Exception {
- File iniFile = new File("AdjustTime.ini");
- File orgFile = new File("AdjustTime.ini.org");
- File testFile = new File("target/test-classes/ini", "AdjustTime.on.ini");
-
- if (orgFile.exists()) {
- orgFile.delete();
- }
- if (iniFile.exists()) {
- iniFile.renameTo(orgFile);
- }
-
- FileInputStream inStream = new FileInputStream(testFile);
- FileOutputStream outStream = new FileOutputStream(new File("AdjustTime.ini"));
- FileChannel inChannel = inStream.getChannel();
- FileChannel outChannel = outStream.getChannel();
- try {
- inChannel.transferTo(0, inChannel.size(),outChannel);
- }
- finally {
- if (inChannel != null) inChannel.close();
- if (outChannel != null) outChannel.close();
- inStream.close();
- outStream.close();
- }
+ delTestData("AdjustTime.ini");
+ setupTestData("AdjustTime.on.ini", "AdjustTime.ini");
}
@After
public void tearDown() throws Exception {
- File iniFile = new File("AdjustTime.ini");
- File orgFile = new File("AdjustTime.ini.org");
- if (iniFile.exists()) {
- iniFile.delete();
- }
- if (orgFile.exists()) {
- orgFile.renameTo(iniFile);
- }
+ delTestData("AdjustTime.ini");
}
@Test
@@ -105,7 +60,7 @@
try {
AppParameters params = new AppParameters();
String valueStr = params.getProperty(AppParameters.IMG_OUTPUT_ALL);
- assertThat(valueStr, is("true"));
+ assertTrue(Boolean.valueOf(valueStr));
}
catch (IOException e) {
fail("Exceptionが発生した。");
@@ -120,7 +75,7 @@
params.store();
AppParameters newParams = new AppParameters();
String valueStr = newParams.getProperty(AppParameters.IMG_OUTPUT_ALL);
- assertThat(valueStr, is("false"));
+ assertFalse(Boolean.valueOf(valueStr));
}
catch (IOException e) {
fail("Exceptionが発生した。");
@@ -132,42 +87,13 @@
@Before
public void setUp() throws Exception {
- File iniFile = new File("AdjustTime.ini");
- File orgFile = new File("AdjustTime.ini.org");
- File testFile = new File("target/test-classes/ini", "AdjustTime.off.ini");
-
- if (orgFile.exists()) {
- orgFile.delete();
- }
- if (iniFile.exists()) {
- iniFile.renameTo(orgFile);
- }
-
- FileInputStream inStream = new FileInputStream(testFile);
- FileOutputStream outStream = new FileOutputStream(new File("AdjustTime.ini"));
- FileChannel inChannel = inStream.getChannel();
- FileChannel outChannel = outStream.getChannel();
- try {
- inChannel.transferTo(0, inChannel.size(),outChannel);
- }
- finally {
- if (inChannel != null) inChannel.close();
- if (outChannel != null) outChannel.close();
- inStream.close();
- outStream.close();
- }
+ delTestData("AdjustTime.ini");
+ setupTestData("AdjustTime.off.ini", "AdjustTime.ini");
}
@After
public void tearDown() throws Exception {
- File iniFile = new File("AdjustTime.ini");
- File orgFile = new File("AdjustTime.ini.org");
- if (iniFile.exists()) {
- iniFile.delete();
- }
- if (orgFile.exists()) {
- orgFile.renameTo(iniFile);
- }
+ delTestData("AdjustTime.ini");
}
@Test
@@ -175,7 +101,7 @@
try {
AppParameters params = new AppParameters();
String valueStr = params.getProperty(AppParameters.IMG_OUTPUT_ALL);
- assertThat(valueStr, is("false"));
+ assertFalse(Boolean.valueOf(valueStr));
}
catch (IOException e) {
fail("Exceptionが発生した。");
@@ -190,11 +116,35 @@
params.store();
AppParameters newParams = new AppParameters();
String valueStr = newParams.getProperty(AppParameters.IMG_OUTPUT_ALL);
- assertThat(valueStr, is("true"));
+ assertTrue(Boolean.valueOf(valueStr));
}
catch (IOException e) {
fail("Exceptionが発生した。");
}
}
}
+
+ static void delTestData(String filename) {
+ File iniFile = new File(filename);
+ if (iniFile.exists()) {
+ iniFile.delete();
+ }
+ }
+
+ static void setupTestData(String sfilename, String dfilename) throws IOException {
+ File testFile = new File("target/test-classes/ini", sfilename);
+ FileInputStream inStream = new FileInputStream(testFile);
+ FileOutputStream outStream = new FileOutputStream(new File(dfilename));
+ FileChannel inChannel = inStream.getChannel();
+ FileChannel outChannel = outStream.getChannel();
+ try {
+ inChannel.transferTo(0, inChannel.size(),outChannel);
+ }
+ finally {
+ if (inChannel != null) inChannel.close();
+ if (outChannel != null) outChannel.close();
+ inStream.close();
+ outStream.close();
+ }
+ }
}
diff --git a/src/test/java/osm/jp/gpx/ElementMapTRKPTTest.java b/src/test/java/osm/jp/gpx/ElementMapTRKPTTest.java
index f034fda..6820b27 100644
--- a/src/test/java/osm/jp/gpx/ElementMapTRKPTTest.java
+++ b/src/test/java/osm/jp/gpx/ElementMapTRKPTTest.java
@@ -8,6 +8,8 @@
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
+
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
@@ -42,6 +44,11 @@
map.put(new Date(timeL), null); // 5-6: 2018-10-25 08:00:00.000
}
+ @After
+ public void tearDown() throws Exception {
+ AppParametersTest.delTestData("AdjustTime.ini");
+ }
+
@Test
public void 同一キーをPUTした場合() {
assertThat(map.size(), is(6));
@@ -106,6 +113,11 @@
}
}
+ @After
+ public void tearDown() throws Exception {
+ AppParametersTest.delTestData("AdjustTime.ini");
+ }
+
@Test
public void コンテンツの数をチェック() {
assertThat(map.size(), is(4));
diff --git a/src/test/java/osm/jp/gpx/ElementMapTRKSEGTest.java b/src/test/java/osm/jp/gpx/ElementMapTRKSEGTest.java
index 1634b70..24b152d 100644
--- a/src/test/java/osm/jp/gpx/ElementMapTRKSEGTest.java
+++ b/src/test/java/osm/jp/gpx/ElementMapTRKSEGTest.java
@@ -7,6 +7,7 @@
import javax.xml.parsers.ParserConfigurationException;
+import org.junit.After;
import org.junit.Test;
import org.junit.experimental.theories.DataPoints;
import org.junit.experimental.theories.Theories;
@@ -51,6 +52,11 @@
//new Fixture("target/test-classes/gpx/multiTRKSEG.eTrex_20J.gpx.xml", 3),
//new Fixture("target/test-classes/gpx/multiTRKSEGreverse.eTrex_20J.gpx.xml", 3),
};
+
+ @After
+ public void tearDown() throws Exception {
+ AppParametersTest.delTestData("AdjustTime.ini");
+ }
@Theory
public void TRKSEGを読み込む(Fixture dataset) {