/** * getNoEmptyListのテストケース * * @throws Exception */ @Test public void getNoEmptyList01() throws Exception { ConfigurationLoader.init(properties_db, false, false); Properties p = ConfigurationLoader.getProperty(); p.setProperty("clean.hdfs-dir.0", "abc"); p.setProperty("clean.hdfs-dir.1", ""); p.setProperty("clean.hdfs-dir.3", "jkl"); ConfigurationLoader.setProperty(p); List<String> list = new ArrayList<String>(); list.add("clean.hdfs-dir.0"); list.add("clean.hdfs-dir.1"); list.add("clean.hdfs-dir.3"); list.add("clean.hdfs-dir.4"); List<String> resultList = ConfigurationLoader.getExistValueList(list); assertEquals(2, resultList.size()); assertEquals("clean.hdfs-dir.0", resultList.get(0)); assertEquals("clean.hdfs-dir.3", resultList.get(1)); resultList = ConfigurationLoader.getExistValueList(null); assertEquals(0, resultList.size()); resultList = ConfigurationLoader.getExistValueList(new ArrayList<String>()); assertEquals(0, resultList.size()); }
/** * checkAndSetParamDBのテストケース 正常系:Importerのリトライ回数が設定されていないケース(デフォルト値が設定される) * * @throws Exception */ @Test public void checkAndSetParamDB06() throws Exception { ConfigurationLoader.init(properties_db, true, false); Properties p = ConfigurationLoader.getProperty(); p.setProperty("import.retry-count", ""); ConfigurationLoader.setProperty(p); try { ConfigurationLoader.checkAndSetParamDB(); } catch (Exception e) { fail(); e.printStackTrace(); } assertEquals("3", ConfigurationLoader.getProperty(Constants.PROP_KEY_IMP_RETRY_COUNT)); }
/** * checkAndSetParamDBのテストケース 正常系:Exporterのリトライインターバルが設定されていないケース(デフォルト値が設定される) * * @throws Exception */ @Test public void checkAndSetParamDB14() throws Exception { ConfigurationLoader.init(properties_db, true, false); Properties p = ConfigurationLoader.getProperty(); p.setProperty("export.retry-interval", ""); ConfigurationLoader.setProperty(p); try { ConfigurationLoader.checkAndSetParamDB(); } catch (Exception e) { fail(); e.printStackTrace(); } assertEquals("10", ConfigurationLoader.getProperty(Constants.PROP_KEY_EXP_RETRY_INTERVAL)); }
/** * checkAndSetParamDBのテストケース * 正常系:エクスポート処理でExport対象テーブルにデータをコピーする時の最大レコード数が設定されていないケース(デフォルト値が設定される) * * @throws Exception */ @Test public void checkAndSetParamDB18() throws Exception { ConfigurationLoader.init(properties_db, true, false); Properties p = ConfigurationLoader.getProperty(); p.setProperty("export.data-copy-max-count", ""); ConfigurationLoader.setProperty(p); try { ConfigurationLoader.checkAndSetParamDB(); } catch (Exception e) { fail(); e.printStackTrace(); } assertEquals("100000", ConfigurationLoader.getProperty(Constants.PROP_KEY_EXP_COPY_MAX_RECORD)); }
/** * checkAndSetParamDBのテストケース 正常系:Importファイルの圧縮時のバッファサイズ不正なケース * * @throws Exception */ @Test public void checkAndSetParamDB05() throws Exception { ConfigurationLoader.init(properties_db, true, false); Properties p = ConfigurationLoader.getProperty(); p.setProperty("import.zip-comp-buf-size", "a"); ConfigurationLoader.setProperty(p); try { ConfigurationLoader.checkAndSetParamDB(); fail(); } catch (Exception e) { e.printStackTrace(); assertTrue(e instanceof BulkLoaderSystemException); } }
/** * checkAndSetParamDBのテストケース 異常系:Importファイルを置くディレクトリのトップディレクトリが設定されていないケース * * @throws Exception */ @Test public void checkAndSetParamDB24() throws Exception { ConfigurationLoader.init(properties_db, true, false); Properties p = ConfigurationLoader.getProperty(); p.setProperty("import.tsv-create-dir", ""); ConfigurationLoader.setProperty(p); try { ConfigurationLoader.checkAndSetParamDB(); fail(); } catch (Exception e) { assertTrue(e instanceof BulkLoaderSystemException); e.printStackTrace(); } }
/** * checkAndSetParamDBのテストケース 異常系:エクスポート正常終了時のTSVファイル削除有無が不正なケース * * @throws Exception */ @Test public void checkAndSetParamDB31() throws Exception { ConfigurationLoader.init(properties_db, true, false); Properties p = ConfigurationLoader.getProperty(); p.setProperty("export.delete-tsv", "2"); ConfigurationLoader.setProperty(p); try { ConfigurationLoader.checkAndSetParamDB(); fail(); } catch (Exception e) { e.printStackTrace(); assertTrue(e instanceof BulkLoaderSystemException); } }
/** * checkAndSetParamHCのテストケース 正常系:エクスポートファイルをTSVファイルに変換する際のファイル分割サイズが不正なケース * * @throws Exception */ @Test public void checkAndSetParamHC06() throws Exception { ConfigurationLoader.init(properties_hc, false, true); Properties p = ConfigurationLoader.getProperty(); p.setProperty("export.tsv-max-size", "a"); ConfigurationLoader.setProperty(p); try { ConfigurationLoader.checkAndSetParamHC(); fail(); } catch (Exception e) { e.printStackTrace(); assertTrue(e instanceof BulkLoaderSystemException); } }
/** * checkAndSetParamHCのテストケース 正常系:エクスポートファイルをTSVファイルに変換する際のファイル分割サイズが設定されていないケース(デフォルト値が設定される) * * @throws Exception */ @Test public void checkAndSetParamHC05() throws Exception { ConfigurationLoader.init(properties_hc, false, true); Properties p = ConfigurationLoader.getProperty(); p.setProperty("export.tsv-max-size", ""); ConfigurationLoader.setProperty(p); try { ConfigurationLoader.checkAndSetParamHC(); } catch (Exception e) { fail(); e.printStackTrace(); } assertEquals("16777216", ConfigurationLoader.getProperty(Constants.PROP_KEY_EXP_LOAD_MAX_SIZE)); }
/** * checkAndSetParamDBのテストケース 正常系:Exportファイルの圧縮時のバッファサイズが設定されていないケース(デフォルト値が設定される) * * @throws Exception */ @Test public void checkAndSetParamDB10() throws Exception { ConfigurationLoader.init(properties_db, true, false); Properties p = ConfigurationLoader.getProperty(); p.setProperty("export.zip-comp-buf-size", ""); ConfigurationLoader.setProperty(p); try { ConfigurationLoader.checkAndSetParamDB(); } catch (Exception e) { fail(); e.printStackTrace(); } assertEquals( "32768", ConfigurationLoader.getProperty(Constants.PROP_KEY_EXP_FILE_COMP_BUFSIZE)); }
/** * checkAndSetParamHCのテストケース 異常系:HDFSのプロトコルとホスト名が設定されていないケース * * @throws Exception */ @Ignore("hdfs-protocol-host is obsoleted") @Test public void checkAndSetParamHC04() throws Exception { ConfigurationLoader.init(properties_hc, false, true); Properties p = ConfigurationLoader.getProperty(); p.setProperty("hdfs-protocol-host", ""); ConfigurationLoader.setProperty(p); try { ConfigurationLoader.checkAndSetParamHC(); fail(); } catch (Exception e) { e.printStackTrace(); assertTrue(e instanceof BulkLoaderSystemException); } }
/** * checkAndSetParamDBのテストケース 異常系:Collectorのシェル名が設定されていないケース * * @throws Exception */ @Ignore(Constants.PROP_KEY_COL_SHELL_NAME + " is obsoleted") @Test public void checkAndSetParamDB27() throws Exception { ConfigurationLoader.init(properties_db, true, false); Properties p = ConfigurationLoader.getProperty(); p.setProperty(Constants.PROP_KEY_COL_SHELL_NAME, ""); ConfigurationLoader.setProperty(p); try { ConfigurationLoader.checkAndSetParamDB(); fail(); } catch (Exception e) { assertTrue(e instanceof BulkLoaderSystemException); e.printStackTrace(); } }
/** * checkAndSetParamHCのテストケース 正常系:出力ファイルの圧縮有無が設定されていないケース(デフォルト値が設定される) * * @throws Exception */ @Test public void checkAndSetParamHC07() throws Exception { ConfigurationLoader.init(properties_hc, false, true); Properties p = ConfigurationLoader.getProperty(); p.setProperty("import.seq-comp-type", ""); ConfigurationLoader.setProperty(p); try { ConfigurationLoader.checkAndSetParamHC(); } catch (Exception e) { fail(); e.printStackTrace(); } assertEquals( "NONE", ConfigurationLoader.getProperty(Constants.PROP_KEY_IMP_SEQ_FILE_COMP_TYPE)); }
/** * checkAndSetParamDBのテストケース 正常系:エクスポート正常終了時のTSVファイル削除有無が設定されていないケース(デフォルト値が設定される) * * @throws Exception */ @Test public void checkAndSetParamDB30() throws Exception { ConfigurationLoader.init(properties_db, true, false); Properties p = ConfigurationLoader.getProperty(); p.setProperty("export.delete-tsv", ""); ConfigurationLoader.setProperty(p); try { ConfigurationLoader.checkAndSetParamDB(); } catch (Exception e) { fail(); e.printStackTrace(); } assertEquals( TsvDeleteType.find(Constants.PROP_DEFAULT_EXPORT_TSV_DELETE), TsvDeleteType.find(ConfigurationLoader.getProperty(Constants.PROP_KEY_EXPORT_TSV_DELETE))); }
/** * checkAndSetParamDBのテストケース 正常系:Importファイルの圧縮有無が設定されていないケース(デフォルト値が設定される) * * @throws Exception */ @Test public void checkAndSetParamDB02() throws Exception { ConfigurationLoader.init(properties_db, true, false); Properties p = ConfigurationLoader.getProperty(); p.setProperty("import.zip-comp-type", ""); ConfigurationLoader.setProperty(p); try { ConfigurationLoader.checkAndSetParamDB(); } catch (Exception e) { fail(); e.printStackTrace(); } assertEquals( FileCompType.STORED, FileCompType.find(ConfigurationLoader.getProperty(Constants.PROP_KEY_IMP_FILE_COMP_TYPE))); }
/** * checkAndSetParamHCのテストケース 正常系:ワーキングディレクトリベースが設定されていないケース * * @throws Exception */ @Ignore("hadoop-cluster.workingdir.use is obsoleted") @Test public void checkAndSetParamHC03() throws Exception { ConfigurationLoader.init(properties_hc, false, true); Properties p = ConfigurationLoader.getProperty(); p.setProperty("hadoop-cluster.workingdir.use", ""); ConfigurationLoader.setProperty(p); try { ConfigurationLoader.checkAndSetParamHC(); } catch (Exception e) { fail(); e.printStackTrace(); } assertEquals("false", ConfigurationLoader.getProperty(Constants.PROP_KEY_WORKINGDIR_USE)); }
/** * checkAndSetParamのテストケース 正常系:log4j.xmlのパスが設定されていないケース(デフォルト値が設定される) * * @throws Exception */ @Test public void checkAndSetParam01() throws Exception { ConfigurationLoader.init(properties_hc, false, true); Properties p = ConfigurationLoader.getProperty(); p.setProperty("log.conf-path", ""); ConfigurationLoader.setProperty(p); try { ConfigurationLoader.checkAndSetParam(); } catch (Exception e) { fail(); e.printStackTrace(); } assertEquals( new File("bulkloader/conf/log4j.xml").getCanonicalPath(), ConfigurationLoader.getProperty(Constants.PROP_KEY_LOG_CONF_PATH)); }
/** * loadJDBCPropのテストケース 異常系:DBMSのDB名が設定されていないケース * * @throws Exception */ @Test public void loadJDBCProp07() throws Exception { // ConfigurationLoader.init(propertys_db, true, false); // // LogInitializer.execute(ConfigurationLoader.getProperty(Constants.PROP_KEY_LOG_CONF_PATH)); ConfigurationLoader.init(properties_db, false, false); Properties p = ConfigurationLoader.getProperty(); p.setProperty("jdbc.driver", "com.mysql.jdbc.Driver"); p.setProperty("jdbc.url", "jdbc:mysql://localhost/asakusa"); p.setProperty("jdbc.user", "asakusa"); p.setProperty("jdbc.password", "asakusa"); p.setProperty("db.parameter", PATH_DB_PARAMETER); ConfigurationLoader.setProperty(p); try { ConfigurationLoader.loadJDBCProp("target2"); } catch (BulkLoaderSystemException e) { LOG.info(e.getCause(), e.getMessageId(), e.getMessageArgs()); } }
/** * getPropStartWithStringのテストケース * * @throws Exception */ @Test public void getPropStartWithString01() throws Exception { ConfigurationLoader.init(properties_db, false, false); Properties p = ConfigurationLoader.getProperty(); p.setProperty("clean.hdfs-dir.0", "abc"); p.setProperty("clean.hdfs-dir.1", "def"); p.setProperty("clean.hdfs-dir.2", "ghi"); p.setProperty("clean.hdfs-dir.3", "jkl"); p.setProperty("clean.hdfs-dir1.0", "xxx"); p.setProperty("clean.hdfs.0", "xxx"); p.setProperty("clean.hdfs-dir", "xxx"); ConfigurationLoader.setProperty(p); List<String> list = ConfigurationLoader.getPropStartWithString("clean.hdfs-dir."); assertEquals(4, list.size()); assertEquals("clean.hdfs-dir.3", list.get(0)); assertEquals("clean.hdfs-dir.2", list.get(1)); assertEquals("clean.hdfs-dir.1", list.get(2)); assertEquals("clean.hdfs-dir.0", list.get(3)); }