import java.io.File;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
INSTANCE;
private final XMLConfiguration config = new XMLConfiguration();
+ void clear() {
+ config.clear();
+ }
+
/*
* ネットワーク - アカウント
*/
private static final String PROXY_HOST = "network.proxy.host";
public String getProxyHost() {
- return config.getString(PROXY_HOST, "");
+ return config.getString(PROXY_HOST, "localhost");
}
public void setProxyHost(String s) {
config.setProperty(PROXY_HOST, s);
}
+ private static final String PROXY_PORT = "network.proxy.port";
+
+ public String getProxyPort() {
+ return config.getString(PROXY_PORT, "8080");
+ }
+
+ public void setProxyPort(String s) {
+ config.setProperty(PROXY_PORT, s);
+ }
/*
* ファイル - 動画
*/
private static final String FILE_VIDEO_DIR = "file.video.dir";
- public File getVideoDir() {
- return new File(config.getString(FILE_VIDEO_DIR, "in/video"));
+ public String getVideoDir() {
+ return config.getString(FILE_VIDEO_DIR, "in/video");
}
- public void setVideoDir(File s) {
- config.setProperty(FILE_VIDEO_DIR, s.toString());
+ public void setVideoDir(String s) {
+ config.setProperty(FILE_VIDEO_DIR, s);
}
private static final String FILE_VIDEO_FILENAME = "file.video.filename";
*/
private static final String FILE_COMMENT_DIR = "file.comment.dir";
- public File getCommentDir() {
- return new File(config.getString(FILE_COMMENT_DIR, "in/comment"));
+ public String getCommentDir() {
+ return config.getString(FILE_COMMENT_DIR, "in/comment");
}
- public void setCommentDir(File s) {
- config.setProperty(FILE_COMMENT_DIR, s.toString());
+ public void setCommentDir(String s) {
+ config.setProperty(FILE_COMMENT_DIR, s);
}
private static final String FILE_COMMENT_FILENAME = "file.comment.filename";
*/
private static final String FILE_OUTPUT_DIR = "file.output.dir";
- public File getOutputDir() {
- return new File(config.getString(FILE_OUTPUT_DIR, "out"));
+ public String getOutputDir() {
+ return config.getString(FILE_OUTPUT_DIR, "out");
}
- public void setOutputDir(File s) {
- config.setProperty(FILE_OUTPUT_DIR, s.toString());
+ public void setOutputDir(String s) {
+ config.setProperty(FILE_OUTPUT_DIR, s);
}
private static final String FILE_OUTPUT_FILENAME = "file.output.filename";
if (source == useMovieLocalCheckBox) {
btn = movieFileSelectButton;
field = movieFileField;
- dir = p.getVideoDir();
+ dir = new File(p.getVideoDir());
} else {
btn = commentFileSelectButton;
field = commentFileField;
- dir = p.getCommentDir();
+ dir = new File(p.getCommentDir());
}
final boolean useLocal = (evt.getStateChange() == ItemEvent.SELECTED);
}
if (useMovieLocalCheckBox.isSelected() && movieFileField.getText().isEmpty()) {
- final File dir = p.getVideoDir();
+ final File dir = new File(p.getVideoDir());
final File file = searchFileMatchId(dir, id);
if (file != null) {
movieFileField.setText(file.getPath());
}
if (useCommentLocalCheckBox.isSelected() && commentFileField.getText().isEmpty()) {
- final File dir = p.getCommentDir();
+ final File dir = new File(p.getCommentDir());
final File file = searchFileMatchId(dir, id);
if (file != null) {
commentFileField.setText(file.getPath());
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import org.apache.commons.configuration.ConfigurationException;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
/**
*/
public class PropertiesTest {
+ private final Properties p = Properties.INSTANCE;
+
+ @Before
+ public void setUp() {
+ Properties.INSTANCE.clear();
+ }
+
+ @After
+ public void tearDown() {
+ Properties.INSTANCE.clear();
+ }
+
@Test
public void testLoadFail() {
FileSystem fs = FileSystems.getDefault();
fail("ファイルが存在しないので読み込みに失敗するはず");
} catch (ConfigurationException ex) {
}
- try{
+ try {
p.load("test/testdata/inqubus_test.xml");
fail("ファイルが空なので読み込みに失敗するはず");
} catch (ConfigurationException ex) {
// System.out.println(f.get(p));
// }
// }
+ @Test
+ public void testGetSetNetworkAccount() {
+ }
+ /**
+ * コンフィグ取得・設定テストケース.
+ * デフォルト値の取得、設定とその設定値の取得のテストです.
+ */
@Test
- public void testCreteConfig() throws ConfigurationException{
- Properties p = Properties.INSTANCE;
- p.setCommentUseLocal(false);
- p.save(new File("test/testdata/save.xml"));
+ public void testGetSetNetworkProxy() throws ConfigurationException {
+
+ /*
+ * ネットワーク - アカウント
+ */
+ assertEquals("", p.getId());
+ p.setId("id");
+ assertEquals("id", p.getId());
+
+ assertEquals("", p.getPassword());
+ p.setPassword("password");
+ assertEquals("password", p.getPassword());
+
+
+ /*
+ * ネットワーク - プロキシ
+ */
+ assertEquals(false, p.getUseProxy());
+ p.setUseProxy(true);
+ assertEquals(true, p.getUseProxy());
+
+ assertEquals("localhost", p.getProxyHost());
+ p.setProxyHost("proxyhost");
+ assertEquals("proxyhost", p.getProxyHost());
+
+ assertEquals("8080", p.getProxyPort());
+ p.setProxyPort("80");
+ assertEquals("80", p.getProxyPort());
+
+
+ /*
+ * ファイル - 動画
+ */
+ assertEquals("in/video", p.getVideoDir());
+ p.setVideoDir("v");
+ assertEquals("v", p.getVideoDir());
+
+ assertEquals("[{id}]{title}", p.getVideoFileNamePattern());
+ p.setVideoFileNamePattern("videotitle");
+ assertEquals("videotitle", p.getVideoFileNamePattern());
+
+ assertEquals(false, p.getVideoUseLocal());
+ p.setVideoUseLocal(true);
+ assertEquals(true, p.getVideoUseLocal());
+
+ /*
+ * ファイル - コメント
+ */
+ assertEquals("in/comment", p.getCommentDir());
+ p.setCommentDir("c");
+ assertEquals("c", p.getCommentDir());
+
+ assertEquals("[{id}]{title}", p.getCommentFileNamePattern());
+ p.setVideoFileNamePattern("comtitle");
+ assertEquals("comtitle", p.getVideoFileNamePattern());
+
+ assertEquals(false, p.getCommentUseLocal());
+ p.setCommentUseLocal(true);
+ assertEquals(true, p.getCommentUseLocal());
+
+
+ /*
+ * ファイル - 変換動画
+ */
+ assertEquals("out", p.getOutputDir());
+ p.setOutputDir("_out_");
+ assertEquals("_out_", p.getOutputDir());
+
+// p.save(new File("test/testdata/save.xml"));
}
}