Package com.asakusafw.testtools

Examples of com.asakusafw.testtools.TestUtils


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

        // プロパティを書き換え
        Properties prop = ConfigurationLoader.getProperty();
        prop.setProperty(Constants.PROP_KEY_EXP_COPY_MAX_RECORD, "1");
        ConfigurationLoader.setProperty(prop);

        // ExportBeanを生成
        Map<String, ExportTargetTableBean> targetTable = new LinkedHashMap<String, ExportTargetTableBean>();
        ExportTargetTableBean table1 = new ExportTargetTableBean();
        table1.setDuplicateCheck(true);
        table1.setExportTempTableName("TEMP_IMPORT_TARGET1");
        table1.setDuplicateFlagTableName("TEMP_IMPORT_TARGET1_DF");
        table1.setExportTableColumns(Arrays.asList(new String[]{"TEXTDATA1", "INTDATA1"}));
        table1.setErrorTableName("IMPORT_TARGET1_ERROR");
        table1.setErrorTableColumns(Arrays.asList(new String[]{"TEXTDATA1", "INTDATA1", "DATEDATA1"}));
        table1.setErrorCodeColumn("ERROR_CODE");
        table1.setErrorCode("ERR01");
        targetTable.put("IMPORT_TARGET1", table1);
        ExportTargetTableBean table2 = new ExportTargetTableBean();
        table2.setDuplicateCheck(true);
        table2.setExportTempTableName("TEMP_IMPORT_TARGET2");
        table2.setDuplicateFlagTableName("TEMP_IMPORT_TARGET2_DF");
        table2.setExportTableColumns(Arrays.asList(new String[]{"TEXTDATA2", "INTDATA2", "DATEDATA2"}));
        table2.setErrorTableName("IMPORT_TARGET2_ERROR");
        table2.setErrorTableColumns(Arrays.asList(new String[]{"TEXTDATA2", "INTDATA2", "DATEDATA2"}));
        table2.setErrorCodeColumn("ERROR_CODE");
        table2.setErrorCode("ERR02");
        targetTable.put("IMPORT_TARGET2", table2);
        ExporterBean bean = new ExporterBean();
        bean.setExportTargetTable(targetTable);
        bean.setJobflowSid("11");
        bean.setJobflowId(jobflowId);
        bean.setExecutionId(executionId);

        // テスト対象クラスを生成
        ExportDataCopy copy = new ExportDataCopy();

        // テスト対象クラス実行
        boolean result = copy.copyData(bean);

        // 実行結果の検証
        assertTrue(result);
        assertFalse(copy.isUpdateEnd());

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


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

        // ExportBeanを生成
        Map<String, ExportTargetTableBean> targetTable = new LinkedHashMap<String, ExportTargetTableBean>();
        ExportTargetTableBean table1 = new ExportTargetTableBean();
        table1.setDuplicateCheck(false);
        table1.setExportTableColumns(Arrays.asList(new String[]{"TEXTDATA1", "INTDATA1"}));
        targetTable.put("IMPORT_TARGET1", table1);
        ExportTargetTableBean table2 = new ExportTargetTableBean();
        table2.setDuplicateCheck(false);
        table2.setExportTableColumns(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);

        // テスト対象クラスを生成
        ExportDataCopy copy = new ExportDataCopy();

        // テスト対象クラス実行
        boolean result = copy.copyData(bean);

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

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

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

        // プロパティを書き換え
        Properties prop = ConfigurationLoader.getProperty();
        prop.setProperty(Constants.PROP_KEY_EXP_COPY_MAX_RECORD, "1");
        ConfigurationLoader.setProperty(prop);

        // ExportBeanを生成
        Map<String, ExportTargetTableBean> targetTable = new LinkedHashMap<String, ExportTargetTableBean>();
        ExportTargetTableBean table1 = new ExportTargetTableBean();
        table1.setDuplicateCheck(true);
        table1.setExportTempTableName("TEMP_IMPORT_TARGET1");
        table1.setDuplicateFlagTableName("TEMP_IMPORT_TARGET1_DF");
        table1.setExportTableColumns(Arrays.asList(new String[]{"TEXTDATA1", "INTDATA1"}));
        table1.setErrorTableName("IMPORT_TARGET1_ERROR");
        table1.setErrorTableColumns(Arrays.asList(new String[]{"TEXTDATA1", "INTDATA1", "DATEDATA1"}));
        table1.setErrorCodeColumn("ERROR_CODE");
        table1.setErrorCode("ERR01");
        targetTable.put("IMPORT_TARGET1", table1);
        ExportTargetTableBean table2 = new ExportTargetTableBean();
        table2.setDuplicateCheck(true);
        table2.setExportTempTableName("TEMP_IMPORT_TARGET2");
        table2.setDuplicateFlagTableName("TEMP_IMPORT_TARGET2_DF");
        table2.setExportTableColumns(Arrays.asList(new String[]{"TEXTDATA2", "INTDATA2", "DATEDATA2"}));
        table2.setErrorTableName("IMPORT_TARGET2_ERROR");
        table2.setErrorTableColumns(Arrays.asList(new String[]{"TEXTDATA2", "INTDATA2", "DATEDATA2"}));
        table2.setErrorCodeColumn("ERROR_CODE");
        table2.setErrorCode("ERR02");
        targetTable.put("IMPORT_TARGET2", table2);
        ExporterBean bean = new ExporterBean();
        bean.setExportTargetTable(targetTable);
        bean.setJobflowSid("11");
        bean.setJobflowId(jobflowId);
        bean.setExecutionId(executionId);

        // テスト対象クラスを生成
        ExportDataCopy copy = new ExportDataCopy();

        // テスト対象クラス実行
        boolean result = copy.copyData(bean);

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

        // 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 executeTest28() throws Exception {
        // テストデータを指定
        File testDataDir = new File("src/test/data/recoverer/executeTest28");
        TestUtils util = new TestUtils(testDataDir);
        // テストデータをセット
        util.storeToDatabase(false);

        // 処理の実行
        String[] args = new String[]{targetName};
        Recoverer recoverer = new StubRecoverer();
        int result = recoverer.execute(args);

        // 実行結果の検証
        assertEquals(1, 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 lockTest01() throws Exception {
        // テストデータを指定
        File testDataDir = new File("src/test/data/importer/TargetDataLockTest/lockTest01");
        TestUtils util = new TestUtils(testDataDir);
        // テストデータをセット
        util.storeToDatabase(false);

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

        // ImportBeanを生成
        Map<String, ImportTargetTableBean> targetTable = new LinkedHashMap<String, ImportTargetTableBean>();
        ImportTargetTableBean tableBean = new ImportTargetTableBean();
        tableBean.setImportTargetColumns(Arrays.asList(new String[]{"TEXTDATA1", "INTDATA1", "DATEDATA1"}));
        tableBean.setSearchCondition(null);
        tableBean.setUseCache(false);
        tableBean.setLockType(ImportTableLockType.TABLE);
        tableBean.setLockedOperation(ImportTableLockedOperation.ERROR);
        tableBean.setImportTargetType(null);
        tableBean.setDfsFilePath(null);
        targetTable.put("IMPORT_TARGET1", tableBean);
        ImportBean bean = createBean(new String[]{jobflowId, executionId, "20101021221015", "3", "5"}, targetTable);

        // テスト対象クラス実行
        TargetDataLock lock = new TargetDataLock();
        boolean result = lock.lock(bean);

        // 実行結果の検証
        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 lockTest02() throws Exception {
        // テストデータを指定
        File testDataDir = new File("src/test/data/importer/TargetDataLockTest/lockTest02");
        TestUtils util = new TestUtils(testDataDir);
        // テストデータをセット
        util.storeToDatabase(false);

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

        // ImportBeanを生成
        Map<String, ImportTargetTableBean> targetTable = new LinkedHashMap<String, ImportTargetTableBean>();
        ImportTargetTableBean tableBean1 = new ImportTargetTableBean();
        tableBean1.setImportTargetColumns(Arrays.asList(new String[]{"TEXTDATA1", "INTDATA1", "DATEDATA1"}));
        tableBean1.setSearchCondition("INTDATA1=11");
        tableBean1.setUseCache(false);
        tableBean1.setLockType(ImportTableLockType.NONE);
        tableBean1.setLockedOperation(ImportTableLockedOperation.FORCE);
        tableBean1.setImportTargetType(null);
        tableBean1.setDfsFilePath(null);
        targetTable.put("IMPORT_TARGET1", tableBean1);

        ImportTargetTableBean tableBean2 = new ImportTargetTableBean();
        tableBean2.setImportTargetColumns(Arrays.asList(new String[]{"TEXTDATA2"}));
        tableBean2.setSearchCondition("TEXTDATA2='testdata2-3'");
        tableBean2.setUseCache(false);
        tableBean2.setLockType(ImportTableLockType.RECORD);
        tableBean2.setLockedOperation(ImportTableLockedOperation.OFF);
        tableBean2.setImportTargetType(null);
        tableBean2.setDfsFilePath(null);
        targetTable.put("IMPORT_TARGET2", tableBean2);
        ImportBean bean = createBean(new String[]{jobflowId, executionId, "20101021221015", "3", "5"}, targetTable);

        // テスト対象クラス実行
        TargetDataLock lock = new TargetDataLock();
        boolean result = lock.lock(bean);

        // 実行結果の検証
        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 executeTest29() throws Exception {
        // テストデータを指定
        File testDataDir = new File("src/test/data/recoverer/executeTest01");
        TestUtils util = new TestUtils(testDataDir);
        // テストデータをセット
        util.storeToDatabase(false);

        // 処理の実行
        String[] args = new String[]{targetName, executionId};
        Recoverer recoverer = new StubRecoverer(){
            /**
             * @see com.asakusafw.bulkloader.recoverer.Recoverer#selectRunningJobFlow(java.lang.String)
             */
            @Override
            protected List<ExporterBean> selectRunningJobFlow(
                    String executionId) throws BulkLoaderSystemException {
                ExporterBean bean = new ExporterBean();
                bean.setExecutionId(executionId);
                bean.setBatchId("BATCH03");
                bean.setJobflowId("JOB_FLOW03");
                bean.setJobflowSid("13");
                return Arrays.asList(new ExporterBean[]{bean});
            }
            /* (非 Javadoc)
             * @see com.asakusafw.bulkloader.recoverer.Recoverer#isExecRecovery(com.asakusafw.bulkloader.bean.ExporterBean, boolean)
             */
            @Override
            protected boolean isExecRecovery(ExporterBean exporterBean,
                    boolean hasParam) throws BulkLoaderSystemException {
                return false;
            }
        };
        int result = recoverer.execute(args);

        // 実行結果の検証
        assertEquals(0, 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 lockTest03() throws Exception {
        // テストデータを指定
        File testDataDir = new File("src/test/data/importer/TargetDataLockTest/lockTest03");
        TestUtils util = new TestUtils(testDataDir);
        // テストデータをセット
        util.storeToDatabase(false);

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

        // ImportBeanを生成
        Map<String, ImportTargetTableBean> targetTable = new LinkedHashMap<String, ImportTargetTableBean>();
        ImportTargetTableBean tableBean = new ImportTargetTableBean();
        tableBean.setImportTargetColumns(Arrays.asList(new String[]{"TEXTDATA1", "INTDATA1", "DATEDATA1"}));
        tableBean.setSearchCondition("TEXTDATA1='testdata1-2'");
        tableBean.setUseCache(false);
        tableBean.setLockType(ImportTableLockType.RECORD);
        tableBean.setLockedOperation(ImportTableLockedOperation.ERROR);
        tableBean.setImportTargetType(null);
        tableBean.setDfsFilePath(null);
        targetTable.put("IMPORT_TARGET1", tableBean);
        ImportBean bean = createBean(new String[]{jobflowId, executionId, "20101021221015", "3", "1"}, targetTable);

        // テスト対象クラス実行
        TargetDataLock lock = new TargetDataLock();
        try {
            lock.lock(bean);
            fail();
        } catch (BulkLoaderReRunnableException e) {
            // ok.
        }

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

        UnitTestUtil.executeUpdate(createSql1);
        UnitTestUtil.executeUpdate(dropSql2);
        UnitTestUtil.executeUpdate(createSql2);
        // テストデータを指定
        File testDataDir = new File("src/test/data/recoverer/executeTest29");
        TestUtils util = new TestUtils(testDataDir);
        // テストデータをセット
        util.storeToDatabase(false);

        // 処理の実行
        String[] args = new String[]{targetName};
        Recoverer recoverer = new StubRecoverer();
        int result = recoverer.execute(args);

        // 実行結果の検証
        assertEquals(1, result);

        // DBの結果を検証
        util = new TestUtils(new File("src/test/data/recoverer/executeTest29_assert"));
        util.loadFromDatabase();
        if (!util.inspect()) {
            for (Cause cause : util.getCauses()) {
                System.out.println(cause.getMessage());
            }
            fail(util.getCauseMessage());
        }

        // テンポラリテーブルが存在しない事を確認
        assertFalse(UnitTestUtil.isExistTable(tempTable2));
        // テンポラリテーブルが存在する事を確認
View Full Code Here

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

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

        // ImportBeanを生成
        Map<String, ImportTargetTableBean> targetTable = new LinkedHashMap<String, ImportTargetTableBean>();
        ImportTargetTableBean tableBean1 = new ImportTargetTableBean();
        tableBean1.setImportTargetColumns(Arrays.asList(new String[]{"TEXTDATA1", "INTDATA1", "DATEDATA1"}));
        tableBean1.setSearchCondition("INTDATA1=11");
        tableBean1.setUseCache(false);
        tableBean1.setLockType(ImportTableLockType.RECORD);
        tableBean1.setLockedOperation(ImportTableLockedOperation.ERROR);
        tableBean1.setImportTargetType(null);
        tableBean1.setDfsFilePath(null);
        targetTable.put("IMPORT_TARGET1", tableBean1);

        ImportTargetTableBean tableBean2 = new ImportTargetTableBean();
        tableBean2.setImportTargetColumns(Arrays.asList(new String[]{"TEXTDATA2"}));
        tableBean2.setSearchCondition("TEXTDATA2='testdata2-3'");
        tableBean2.setUseCache(false);
        tableBean2.setLockType(ImportTableLockType.NONE);
        tableBean2.setLockedOperation(ImportTableLockedOperation.ERROR);
        tableBean2.setImportTargetType(null);
        tableBean2.setDfsFilePath(null);
        targetTable.put("IMPORT_TARGET2", tableBean2);
        ImportBean bean = createBean(new String[]{jobflowId, executionId, "20101021221015", "3", "5"}, targetTable);

        // テスト対象クラス実行
        TargetDataLock lock = new TargetDataLock();
        boolean result = lock.lock(bean);

        // 実行結果の検証
        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

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.