Package com.asakusafw.testtools

Examples of com.asakusafw.testtools.TestUtils


    // Linux上ではオープンしているファイルを消すことができるため当テストは成功しない。
    // よって、テスト対象から除外。(Windows上では動作を確認済み)
    public void createImportFileTest05() throws Exception {
        // テストデータを指定
        File testDataDir = new File("src/test/data/importer/ImportFileCreateTest/createImportFileTest05");
        TestUtils util = new TestUtils(testDataDir);
        // テストデータをセット
        util.storeToDatabase(false);

//        // テストデータの指定
//        String pattern = "patternC03";

        FileOutputStream fos = null;
View Full Code Here


     */
    @Test
    public void createImportFileTest06() throws Exception {
        // テストデータを指定
        File testDataDir = new File("src/test/data/importer/ImportFileCreateTest/createImportFileTest06");
        TestUtils util = new TestUtils(testDataDir);
        // テストデータをセット
        util.storeToDatabase(false);

//        // テストデータの指定
//        String pattern = "patternC01";

        // ImportBeanを生成
View Full Code Here

     */
    @Test
    public void createImportFileTest07() throws Exception {
        // テストデータを指定
        File testDataDir = new File("src/test/data/importer/ImportFileCreateTest/createImportFileTest07");
        TestUtils util = new TestUtils(testDataDir);
        // テストデータをセット
        util.storeToDatabase(false);

//        // テストデータの指定
//        String pattern = "patternC01";

        // ImportBeanを生成
View Full Code Here

    @Test
    @Ignore
    public void createImportFileTest08() throws Exception {
        // テストデータを指定
        File testDataDir = new File("src/test/data/importer/ImportFileCreateTest/createImportFileTest01");
        TestUtils util = new TestUtils(testDataDir);
        // テストデータをセット
        util.storeToDatabase(false);

        // テストデータの指定
//        String pattern = "patternC01";

        // ImportBeanを生成
View Full Code Here

     */
    @Test
    public void releaseLockTest01() throws Exception {
        // テストデータを指定
        File testDataDir = new File("src/test/data/exporter/LockReleaseTest/releaseLockTest01");
        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, true);

        // 実行結果の検証
        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"));
View Full Code Here

    @Ignore
    @Test
    public void releaseLockTest02() throws Exception {
        // テストデータを指定
        File testDataDir = new File("src/test/data/exporter/LockReleaseTest/releaseLockTest02");
        TestUtils util = new TestUtils(testDataDir);
        // テストデータをセット
        util.storeToDatabase(false);

        // ExportBeanを生成
        Map<String, ExportTargetTableBean> exportTargetTable = new LinkedHashMap<String, ExportTargetTableBean>();
        Map<String, ImportTargetTableBean> importTargetTable = new LinkedHashMap<String, ImportTargetTableBean>();
        ImportTargetTableBean table1 = new ImportTargetTableBean();
        importTargetTable.put("IMPORT_TARGET1", table1);
        ImportTargetTableBean table2 = new ImportTargetTableBean();
        importTargetTable.put("IMPORT_TARGET2", table2);
        ExporterBean bean = new ExporterBean();
        bean.setJobflowSid("11");
        bean.setExportTargetTable(exportTargetTable);
        bean.setImportTargetTable(importTargetTable);
        bean.setRetryCount(1);
        bean.setRetryInterval(1);

        Connection conn = null;
        PreparedStatement stmt = null;
        try {
            // コネクションを取得する
            conn = DBConnection.getConnection();
            stmt = conn.prepareStatement("update IMPORT_TABLE_LOCK set TABLE_NAME='IMPORT_TARGET1' where JOBFLOW_SID=11 and TABLE_NAME='IMPORT_TARGET1'");
            stmt.executeUpdate();

            // テスト対象クラス実行
            LockRelease lock = new LockRelease(){
                @Override
                protected TempTableDelete createTempTableDelete() {
                    return new TempTableDelete(){
                        @Override
                        public boolean delete(
                                List<ExportTempTableBean> exportTempTableBean, boolean copyNotEnd) {
                            return true;
                        }
                        @Override
                        public void deleteTempInfoRecord(String jobflowSid,
                                String tableName, boolean copyNotEnd, Connection conn)
                                throws BulkLoaderSystemException {
                        }
                        @Override
                        public void deleteTempTable(String exportTempName, String duplicateFlagTableName, boolean copyNotEnd, Connection conn) throws BulkLoaderSystemException {
                        }
                    };
                }
            };
            boolean result = lock.releaseLock(bean, true);

            // 実行結果の検証
            assertFalse(result);

            // DBの結果を検証
            util.loadFromDatabase();
            if (!util.inspect()) {
                for (Cause cause : util.getCauses()) {
                    System.out.println(cause.getMessage());
                }
                fail(util.getCauseMessage());
            }
        } finally {
            DBConnection.rollback(conn);
            DBConnection.closePs(stmt);
            DBConnection.closeConn(conn);
View Full Code Here

     */
    @Test
    public void releaseLockTest04() throws Exception {
        // テストデータを指定
        File testDataDir = new File("src/test/data/exporter/LockReleaseTest/releaseLockTest04");
        TestUtils util = new TestUtils(testDataDir);
        // テストデータをセット
        util.storeToDatabase(false);

        // ExportBeanを生成
        Map<String, ExportTargetTableBean> exportTargetTable = new LinkedHashMap<String, ExportTargetTableBean>();
        ExportTargetTableBean table1 = new ExportTargetTableBean();
        exportTargetTable.put("IMPORT_TARGET1", table1);
        Map<String, ImportTargetTableBean> importTargetTable = new LinkedHashMap<String, ImportTargetTableBean>();
        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(5);

        // テスト対象クラス実行
        LockRelease lock = new LockRelease(){
            @Override
            protected TempTableDelete createTempTableDelete() {
                return new TempTableDelete(){
                    @Override
                    public boolean delete(
                            List<ExportTempTableBean> exportTempTableBean, boolean copyNotEnd) {
                        return true;
                    }
                    @Override
                    public void deleteTempInfoRecord(String jobflowSid,
                            String tableName, boolean copyNotEnd, Connection conn)
                            throws BulkLoaderSystemException {
                    }
                    @Override
                    public void deleteTempTable(String exportTempName, String duplicateFlagTableName, boolean copyNotEnd, Connection conn) throws BulkLoaderSystemException {
                    }
                };
            }
        };
        boolean result = lock.releaseLock(bean, true);

        // 実行結果の検証
        assertTrue(result);

        // DBの結果を検証
        util.loadFromDatabase();
        if (!util.inspect()) {
            for (Cause cause : util.getCauses()) {
                System.out.println(cause.getMessage());
            }
            fail(util.getCauseMessage());
        }
    }
View Full Code Here

     */
    @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"));
View Full Code Here

     */
    @Test
    public void executeTest18() throws Exception {
        // テストデータを指定
        File testDataDir = new File("src/test/data/exporter/Exporter");
        TestUtils util = new TestUtils(testDataDir);
        // テストデータをセット
        util.storeToDatabase(false);

        // 処理の実行
        String[] args = new String[4];
        args[0] = "target1";
        args[1] = "batch01";
View Full Code Here

     */
    @Test
    public void executeTest13() throws Exception {
        // テストデータを指定
        File testDataDir = new File("src/test/data/importer/Importer");
        TestUtils util = new TestUtils(testDataDir);
        // テストデータをセット
        util.storeToDatabase(false);

        // 処理の実行
        String[] args = new String[6];
        args[0] = "primary";
        args[1] = targetName;
View Full Code Here

TOP

Related Classes of com.asakusafw.testtools.TestUtils

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.