Search in sources :

Example 1 with DfTakeFinallyAssertionFailureException

use of org.dbflute.exception.DfTakeFinallyAssertionFailureException in project dbflute-core by dbflute.

the class DfAlterCheckProcess method reflectTakeFinallyResultToFinalInfo.

protected void reflectTakeFinallyResultToFinalInfo(DfAlterCheckFinalInfo finalInfo, DfTakeFinallyFinalInfo takeFinally) {
    final List<String> detailMessageList = takeFinally.getDetailMessageList();
    for (String detailMessage : detailMessageList) {
        finalInfo.addDetailMessage(detailMessage);
    }
    final SQLFailureException breakCause = takeFinally.getBreakCause();
    if (breakCause != null) {
        finalInfo.setBreakCause(breakCause);
    }
    final DfTakeFinallyAssertionFailureException assertionEx = takeFinally.getAssertionEx();
    if (assertionEx != null) {
        finalInfo.setTakeFinallyAssertionEx(assertionEx);
    }
    if (takeFinally.isFailure()) {
        finalInfo.setFailure(true);
    }
}
Also used : DfTakeFinallyAssertionFailureException(org.dbflute.exception.DfTakeFinallyAssertionFailureException) SQLFailureException(org.dbflute.exception.SQLFailureException)

Example 2 with DfTakeFinallyAssertionFailureException

use of org.dbflute.exception.DfTakeFinallyAssertionFailureException in project dbflute-core by dbflute.

the class DfTakeFinallyProcess method execute.

// ===================================================================================
// Execute
// =======
public DfTakeFinallyFinalInfo execute() {
    final long before = System.currentTimeMillis();
    final DfRunnerInformation runInfo = createRunnerInformation();
    DfSqlFileFireResult fireResult = null;
    DfTakeFinallyAssertionFailureException assertionEx = null;
    try {
        fireResult = takeFinally(runInfo);
        if (_continueIfAssetionFailure && !_continuedExList.isEmpty()) {
            // override result with saved exceptions
            // this message uses the first exception
            fireResult = createFailureFireResult(_continuedExList.get(0), fireResult);
        }
    } catch (DfTakeFinallyAssertionFailureException e) {
        // if take-assert, the exception does not thrown
        fireResult = createFailureFireResult(e, null);
        assertionEx = e;
    }
    final DfTakeFinallyFinalInfo finalInfo = createFinalInfo(fireResult, assertionEx);
    if (!finalInfo.isFailure()) {
        // because it might fail to create sequence
        incrementSequenceToDataMax();
    }
    final long after = System.currentTimeMillis();
    final long processPerformanceMillis = after - before;
    finalInfo.setProcessPerformanceMillis(processPerformanceMillis);
    return finalInfo;
}
Also used : DfTakeFinallyAssertionFailureException(org.dbflute.exception.DfTakeFinallyAssertionFailureException) DfTakeFinallyFinalInfo(org.dbflute.logic.replaceschema.finalinfo.DfTakeFinallyFinalInfo) DfSqlFileFireResult(org.dbflute.helper.jdbc.sqlfile.DfSqlFileFireResult) DfRunnerInformation(org.dbflute.helper.jdbc.DfRunnerInformation)

Example 3 with DfTakeFinallyAssertionFailureException

use of org.dbflute.exception.DfTakeFinallyAssertionFailureException in project dbflute-core by dbflute.

the class DfAlterCheckProcess method executeAlterSql.

// -----------------------------------------------------
// Alter Fire
// ----------
protected void executeAlterSql(DfAlterCheckFinalInfo finalInfo) {
    List<File> alterSqlFileList = findMigrationAlterSqlFileList();
    if (alterSqlFileList.isEmpty()) {
        _unreleasedAlterAgent.restoreUnreleasedAlterSql();
        alterSqlFileList = findMigrationAlterSqlFileList();
        if (alterSqlFileList.isEmpty()) {
            createEmptyAlterSqlFileIfNotExists();
            alterSqlFileList = findMigrationAlterSqlFileList();
            if (alterSqlFileList.isEmpty()) {
                // no way
                throwAlterCheckAlterSqlNotFoundException();
            }
        }
    }
    final DfRunnerInformation runInfo = createRunnerInformation();
    final DfSqlFileFireMan fireMan = createSqlFileFireMan();
    final DfSqlFileRunner runner = createSqlFileRunner(runInfo);
    finalInfo.addAlterSqlFileAll(alterSqlFileList);
    try {
        final DfSqlFileFireResult result = fireMan.fire(runner, alterSqlFileList);
        reflectAlterResultToFinalInfo(finalInfo, result);
    } catch (DfTakeFinallyAssertionFailureException e) {
        handleTakeFinallyAssertionFailureException(finalInfo, e);
    }
}
Also used : DfTakeFinallyAssertionFailureException(org.dbflute.exception.DfTakeFinallyAssertionFailureException) DfSqlFileFireMan(org.dbflute.helper.jdbc.sqlfile.DfSqlFileFireMan) DfSqlFileFireResult(org.dbflute.helper.jdbc.sqlfile.DfSqlFileFireResult) DfSqlFileRunner(org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunner) File(java.io.File) DfRunnerInformation(org.dbflute.helper.jdbc.DfRunnerInformation)

Example 4 with DfTakeFinallyAssertionFailureException

use of org.dbflute.exception.DfTakeFinallyAssertionFailureException in project dbflute-core by dbflute.

the class DfTakeAssertTask method dumpAssertionFailure.

protected void dumpAssertionFailure(List<DfTakeFinallyAssertionFailureException> takeAssertExList) {
    final File dumpFile = new File("./log/take-assert.log");
    if (dumpFile.exists()) {
        dumpFile.delete();
    }
    BufferedWriter bw = null;
    try {
        bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(dumpFile), "UTF-8"));
        for (DfTakeFinallyAssertionFailureException assertionEx : takeAssertExList) {
            bw.write(assertionEx.getMessage());
            bw.write(ln() + ln());
        }
        bw.flush();
    } catch (IOException e) {
        if (bw != null) {
            try {
                bw.close();
            } catch (IOException ignored) {
            }
        }
    }
}
Also used : DfTakeFinallyAssertionFailureException(org.dbflute.exception.DfTakeFinallyAssertionFailureException) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) IOException(java.io.IOException) File(java.io.File) BufferedWriter(java.io.BufferedWriter)

Example 5 with DfTakeFinallyAssertionFailureException

use of org.dbflute.exception.DfTakeFinallyAssertionFailureException in project dbflute-core by dbflute.

the class DfTakeAssertTask method buildFinalMessage.

protected String buildFinalMessage() {
    // might be null
    final DfTakeFinallyFinalInfo finalInfo = _finalInfo;
    final List<DfTakeFinallyAssertionFailureException> takeAssertExList = _takeAssertExList;
    final StringBuilder sb = new StringBuilder();
    if (finalInfo != null) {
        if (finalInfo.isValidInfo()) {
            buildSchemaTaskContents(sb, finalInfo);
        }
        if (takeAssertExList != null && !takeAssertExList.isEmpty()) {
            sb.append(ln()).append("    * * * * * * * * * * *");
            sb.append(ln()).append("    * Assertion Failure *");
            sb.append(ln()).append("    * * * * * * * * * * *");
        }
    }
    return sb.toString();
}
Also used : DfTakeFinallyAssertionFailureException(org.dbflute.exception.DfTakeFinallyAssertionFailureException) DfTakeFinallyFinalInfo(org.dbflute.logic.replaceschema.finalinfo.DfTakeFinallyFinalInfo)

Aggregations

DfTakeFinallyAssertionFailureException (org.dbflute.exception.DfTakeFinallyAssertionFailureException)9 File (java.io.File)4 SQLFailureException (org.dbflute.exception.SQLFailureException)3 DfRunnerInformation (org.dbflute.helper.jdbc.DfRunnerInformation)3 DfSqlFileFireResult (org.dbflute.helper.jdbc.sqlfile.DfSqlFileFireResult)3 DfSqlFileFireMan (org.dbflute.helper.jdbc.sqlfile.DfSqlFileFireMan)2 DfSqlFileRunner (org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunner)2 DfTakeFinallyFinalInfo (org.dbflute.logic.replaceschema.finalinfo.DfTakeFinallyFinalInfo)2 BufferedWriter (java.io.BufferedWriter)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStreamWriter (java.io.OutputStreamWriter)1 SQLException (java.sql.SQLException)1 Statement (java.sql.Statement)1 DfSqlFileRunnerDispatcher (org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerDispatcher)1 DfSqlFileRunnerExecute (org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerExecute)1 DfRunnerDispatchResult (org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerExecute.DfRunnerDispatchResult)1 DfDataAssertHandler (org.dbflute.logic.replaceschema.dataassert.DfDataAssertHandler)1 DfDataAssertProvider (org.dbflute.logic.replaceschema.dataassert.DfDataAssertProvider)1 DfTakeFinallyProcess (org.dbflute.logic.replaceschema.process.DfTakeFinallyProcess)1