*/
@Test
public void releaseLockTest06() throws Exception {
// テストデータを指定
File testDataDir = new File("src/test/data/exporter/LockReleaseTest/releaseLockTest06");
TestUtils util = new TestUtils(testDataDir);
// テストデータをセット
util.storeToDatabase(false);
// テンポラリテーブルを作成
String tempTable1 = "EXPORT_TEMP_TEST_01";
String dropSql1 = "DROP TABLE IF EXISTS EXPORT_TEMP_TEST_01";
String createSql1 = "CREATE TABLE EXPORT_TEMP_TEST_01 (TEXTDATA1 VARCHAR(45) NOT NULL ,INTDATA1 INT NULL,PRIMARY KEY (TEXTDATA1)) ENGINE=InnoDB;";
String tempTable2 = "EXPORT_TEMP_TEST_02";
String dropSql2 = "DROP TABLE IF EXISTS EXPORT_TEMP_TEST_02";
String createSql2 = "CREATE TABLE EXPORT_TEMP_TEST_02 (TEXTDATA1 VARCHAR(45) NOT NULL ,INTDATA1 INT NULL,PRIMARY KEY (TEXTDATA1)) ENGINE=InnoDB;";
UnitTestUtil.executeUpdate(dropSql1);
UnitTestUtil.executeUpdate(createSql1);
UnitTestUtil.executeUpdate(dropSql2);
UnitTestUtil.executeUpdate(createSql2);
String dropDup1Sql = "DROP TABLE IF EXISTS EXPORT_TEMP_TEST_01_DF";
String dropDup2Sql = "DROP TABLE IF EXISTS EXPORT_TEMP_TEST_02_DF";
StringBuilder dup1Sql = new StringBuilder();
dup1Sql.append("CREATE TABLE `EXPORT_TEMP_TEST_01_DF` (");
dup1Sql.append(" `TEMP_SID` BIGINT,");
dup1Sql.append(" PRIMARY KEY (`TEMP_SID`) ) ENGINE=InnoDB");
StringBuilder dup2Sql = new StringBuilder();
dup2Sql.append("CREATE TABLE `EXPORT_TEMP_TEST_02_DF` (");
dup2Sql.append(" `TEMP_SID` BIGINT,");
dup2Sql.append(" PRIMARY KEY (`TEMP_SID`) ) ENGINE=InnoDB");
UnitTestUtil.executeUpdate(dropDup1Sql);
UnitTestUtil.executeUpdate(dropDup2Sql);
UnitTestUtil.executeUpdate(dup1Sql.toString());
UnitTestUtil.executeUpdate(dup2Sql.toString());
// ExportBeanを生成
Map<String, ExportTargetTableBean> exportTargetTable = new LinkedHashMap<String, ExportTargetTableBean>();
ExportTargetTableBean table1 = new ExportTargetTableBean();
table1.setExportTempTableName(tempTable1);
table1.setDuplicateFlagTableName("EXPORT_TEMP_TEST_01_DF");
exportTargetTable.put("IMPORT_TARGET1", table1);
ExportTargetTableBean table2 = new ExportTargetTableBean();
table2.setExportTempTableName(tempTable2);
table2.setDuplicateFlagTableName("EXPORT_TEMP_TEST_02_DF");
exportTargetTable.put("IMPORT_TARGET2", table2);
Map<String, ImportTargetTableBean> importTargetTable = new LinkedHashMap<String, ImportTargetTableBean>();
ImportTargetTableBean table3 = new ImportTargetTableBean();
importTargetTable.put("IMPORT_TARGET1", table3);
ImportTargetTableBean table4 = new ImportTargetTableBean();
importTargetTable.put("IMPORT_TARGET2", table4);
ExporterBean bean = new ExporterBean();
bean.setJobflowSid("11");
bean.setExportTargetTable(exportTargetTable);
bean.setImportTargetTable(importTargetTable);
bean.setRetryCount(3);
bean.setRetryInterval(1);
// テスト対象クラス実行
LockRelease lock = new LockRelease();
boolean result = lock.releaseLock(bean, false);
// 実行結果の検証
assertTrue(result);
// DBの結果を検証
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));
assertFalse(UnitTestUtil.isExistTable("EXPORT_TEMP_TEST_01_DF"));