* @throws Exception
*/
@Test
public void loadFileTest02() throws Exception {
// テストデータを指定
TestUtils util1 = new TestUtils(new File("src/test/data/exporter/ExportFileLoadTest/loadFileTest02_load"));
// テストデータをセット
util1.storeToDatabase(false);
// ExportBeanを生成
Map<String, ExportTargetTableBean> targetTable = new LinkedHashMap<String, ExportTargetTableBean>();
ExportTargetTableBean table1 = new ExportTargetTableBean();
table1.setDuplicateCheck(false);
table1.addExportFile(new File(new File ("src/test/data/exporter/EXP_EXP_TARGET1_1.tsv").getAbsolutePath()));
table1.addExportFile(new File(new File ("src/test/data/exporter/EXP_EXP_TARGET1_2.tsv").getAbsolutePath()));
table1.setExportTsvColumns(Arrays.asList(new String[]{"SID", "VERSION_NO", "TEXTDATA1", "INTDATA1", "DATEDATA1"}));
targetTable.put("IMPORT_TARGET1", table1);
ExportTargetTableBean table2 = new ExportTargetTableBean();
table2.setDuplicateCheck(false);
table2.addExportFile(new File(new File ("src/test/data/exporter/EXP_EXP_TARGET2_1.tsv").getAbsolutePath()));
table2.setExportTsvColumns(Arrays.asList(new String[]{"TEXTDATA2", "INTDATA2", "DATEDATA2"}));
targetTable.put("IMPORT_TARGET2", table2);
ExporterBean bean = new ExporterBean();
bean.setExportTargetTable(targetTable);
bean.setJobflowSid("11");
bean.setJobflowId(jobflowId);
bean.setExecutionId(executionId);
// テスト対象クラスを生成
ExportFileLoad load = new ExportFileLoad() {
@Override
protected long getTempSeq(String jobflowSid, String tableName,
Connection conn) throws BulkLoaderSystemException {
return 1;
}
};
try {
// テンポラリテーブルを削除
UnitTestUtil.executeUpdate("DROP TABLE IF EXISTS EXPORT_TEMP_IMPORT_TARGET1_1");
UnitTestUtil.executeUpdate("DROP TABLE IF EXISTS EXPORT_TEMP_IMPORT_TARGET2_1");
UnitTestUtil.executeUpdate("DROP TABLE IF EXISTS EXPORT_TEMP_IMPORT_TARGET1_1_DF");
UnitTestUtil.executeUpdate("DROP TABLE IF EXISTS EXPORT_TEMP_IMPORT_TARGET2_1_DF");
// テスト対象クラス実行
boolean result = load.loadFile(bean);
// 実行結果の検証
assertTrue(result);
// DBの結果を検証
TestUtils util2 = new TestUtils(new File("src/test/data/exporter/ExportFileLoadTest/loadFileTest02_assert"));
util2.loadFromDatabase();
if (!util2.inspect()) {
for (Cause cause : util2.getCauses()) {
System.out.println(cause.getMessage());
}
fail(util2.getCauseMessage());
}
// 重複チェック件数を確認
assertTrue(UnitTestUtil.countAssert("EXPORT_TEMP_IMPORT_TARGET1_1_DF", 0));
assertTrue(UnitTestUtil.countAssert("EXPORT_TEMP_IMPORT_TARGET2_1_DF", 0));
} finally {