UnitTestUtil.executeUpdate(createSql1);
UnitTestUtil.executeUpdate(dropSql2);
UnitTestUtil.executeUpdate(createSql2);
// テストデータを指定
File testDataDir = new File("src/test/data/recoverer/executeTest10");
TestUtils util = new TestUtils(testDataDir);
// テストデータをセット
util.storeToDatabase(false);
// 処理の実行
String[] args = new String[]{targetName, executionId};
Recoverer recoverer = new Recoverer(){
/**
* @see com.asakusafw.bulkloader.recoverer.Recoverer#createJobFlowParamLoader()
*/
@Override
protected JobFlowParamLoader createJobFlowParamLoader() {
JobFlowParamLoader loder = new JobFlowParamLoader(){
@Override
protected Properties getImportProp(File dslFile, String targetName) throws IOException {
Properties prop = new Properties();
prop.setProperty("import.target-table", "IMPORT_TARGET1,IMPORT_TARGET2");
return prop;
}
@Override
protected Properties getExportProp(File dslFile, String targetName) throws IOException {
Properties prop = new Properties();
prop.setProperty("export.target-table", "IMPORT_TARGET1,IMPORT_TARGET2");
prop.setProperty("IMPORT_TARGET1.export-table-column", "TEXTDATA1,INTDATA1,DATEDATA1");
prop.setProperty("IMPORT_TARGET2.export-table-column", "SID,VERSION_NO,TEXTDATA2,INTDATA2,DATEDATA2,RGST_DATE,UPDT_DATE");
prop.setProperty("IMPORT_TARGET1.tsv-column", "SID,VERSION_NO,TEXTDATA1,INTDATA1,DATEDATA1,RGST_DATE,UPDT_DATE");
prop.setProperty("IMPORT_TARGET2.tsv-column", "SID,VERSION_NO,TEXTDATA2,INTDATA2,DATEDATA2,RGST_DATE,UPDT_DATE");
prop.setProperty("IMPORT_TARGET1.error-table", "IMPORT_TARGET1_ERROR");
prop.setProperty("IMPORT_TARGET2.error-table", "IMPORT_TARGET2_ERROR");
prop.setProperty("IMPORT_TARGET1.error-table-column", "SID,VERSION_NO,TEXTDATA1,INTDATA1,DATEDATA1,RGST_DATE,UPDT_DATE");
prop.setProperty("IMPORT_TARGET2.error-table-column", "TEXTDATA2,INTDATA2,DATEDATA2");
prop.setProperty("IMPORT_TARGET1.error-column", "ERROR_CODE");
prop.setProperty("IMPORT_TARGET2.error-column", "ERROR_CODE");
prop.setProperty("IMPORT_TARGET1.error-code", "ERR99");
prop.setProperty("IMPORT_TARGET2.error-code", "99");
return prop;
}
};
return loder;
}
};
int result = recoverer.execute(args);
// 実行結果の検証
assertEquals(0, result);
// DBの結果を検証
util = new TestUtils(new File("src/test/data/recoverer/executeTest10_assert"));
util.loadFromDatabase();
if (!util.inspect()) {
for (Cause cause : util.getCauses()) {
System.out.println(cause.getMessage());
}
fail(util.getCauseMessage());
}
// テンポラリテーブルが存在しない事を確認
assertFalse(UnitTestUtil.isExistTable(tempTable1));
assertFalse(UnitTestUtil.isExistTable(tempTable2));