use of org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerResult in project dbflute-core by dbflute.
the class DfOutsideSqlTestTask method handleSqlFileFailure.
// ===================================================================================
// Exception Handling
// ==================
protected void handleSqlFileFailure(DfSqlFileFireResult fireResult, List<File> sqlFileList) {
final SQLFailureException topCause = fireResult.getBreakCause();
if (topCause != null) {
throw topCause;
}
final List<DfSqlFileRunnerResult> resultList = fireResult.getRunnerResultList();
for (DfSqlFileRunnerResult runnerResult : resultList) {
final SQLFailureException elementCause = runnerResult.getBreakCause();
if (elementCause != null) {
throw elementCause;
}
final List<ErrorContinuedSql> continuedSqlList = runnerResult.getErrorContinuedSqlList();
if (!continuedSqlList.isEmpty()) {
throwOutsideSqlTestFailureFoundException();
}
}
}
use of org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerResult in project dbflute-core by dbflute.
the class DfAlterCheckProcess method createSqlFileFireMan.
protected DfSqlFileFireMan createSqlFileFireMan() {
final String[] scriptExtAry = SystemScript.getSupportedExtList().toArray(new String[] {});
final SystemScript script = new SystemScript();
return new DfSqlFileFireMan() {
@Override
protected DfSqlFileRunnerResult processSqlFile(DfSqlFileRunner runner, File sqlFile) {
_executedAlterSqlFileList.add(sqlFile);
final String path = resolvePath(sqlFile);
if (!Srl.endsWith(path, scriptExtAry)) {
// SQL file
return super.processSqlFile(runner, sqlFile);
}
// script file
final String baseDir = Srl.substringLastFront(path, "/");
final String scriptName = Srl.substringLastRear(path, "/");
_log.info("...Executing the script: " + path);
final ProcessResult processResult;
try {
processResult = script.execute(new File(baseDir), scriptName);
} catch (SystemScriptUnsupportedScriptException ignored) {
_log.info("Skipped the script for system mismatch: " + scriptName);
return null;
}
final String console = processResult.getConsole();
if (Srl.is_NotNull_and_NotTrimmedEmpty(console)) {
_log.info("Catched the console for " + scriptName + ":" + ln() + console);
}
final DfSqlFileRunnerResult runnerResult = new DfSqlFileRunnerResult(sqlFile);
runnerResult.setTotalSqlCount(1);
final int exitCode = processResult.getExitCode();
if (exitCode != 0) {
final String msg = "The script failed: " + scriptName + " exitCode=" + exitCode;
final SQLException sqlEx = new DfAlterCheckAlterScriptSQLException(msg);
final String sqlExp = "(commands on the script)";
runnerResult.addErrorContinuedSql(sqlExp, sqlEx);
return runnerResult;
} else {
runnerResult.setGoodSqlCount(1);
return runnerResult;
}
}
};
}
use of org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerResult in project dbflute-core by dbflute.
the class DfOutsideSqlTestTask method buildFinalMessage.
protected String buildFinalMessage() {
if (_fireResult == null) {
return null;
}
final DfSqlFileFireResult fireResult = _fireResult;
int countOK = 0;
int countSkipped = 0;
int countFailure = 0;
final StringBuilder sb = new StringBuilder();
sb.append(" {Checked SQL}");
final List<DfSqlFileRunnerResult> runnerResultList = fireResult.getRunnerResultList();
for (DfSqlFileRunnerResult runnerResult : runnerResultList) {
final File sqlFile = runnerResult.getSqlFile();
final List<ErrorContinuedSql> continuedSqlList = runnerResult.getErrorContinuedSqlList();
sb.append(ln());
if (continuedSqlList.isEmpty()) {
if (_nonTargetSqlFileSet.contains(sqlFile)) {
// accurately 'v' means the SQL file may have skipped SQLs
// however SQL file for OutsideSqlTest has only one SQL normally
sb.append(" v ");
++countSkipped;
} else {
sb.append(" o ");
++countOK;
}
} else {
// you can say same as 'v'
// (anyway, look at the log for detail)
sb.append(" x ");
++countFailure;
}
sb.append(sqlFile.getName());
for (ErrorContinuedSql errorContinuedSql : continuedSqlList) {
final SQLException sqlEx = errorContinuedSql.getSqlEx();
String sqlMsg = sqlEx.getMessage();
if (sqlMsg != null) {
sqlMsg = sqlMsg.trim();
if (sqlMsg.contains(ln())) {
sqlMsg = Srl.substringFirstFront(sqlMsg, ln()).trim() + "...";
}
}
sb.append(ln()).append(" -> ").append(sqlMsg);
}
}
if (!runnerResultList.isEmpty()) {
sb.append(ln());
sb.append(ln()).append(" o: OK (").append(countOK).append(")");
if (countSkipped > 0) {
sb.append(ln()).append(" v: Skipped exists (").append(countSkipped).append(")");
}
if (countFailure > 0) {
sb.append(ln()).append(" x: Failure exists (").append(countFailure).append(")");
}
}
return sb.toString();
}
Aggregations