use of org.dbflute.bhv.core.BehaviorCommandMeta in project dbflute-core by dbflute.
the class CallbackContextTest method test_BehaviorCommandHook_twiceSet_noInherits.
// ===================================================================================
// BehaviorCommandHook
// ===================
public void test_BehaviorCommandHook_twiceSet_noInherits() throws Exception {
// ## Arrange ##
CallbackContext context = new CallbackContext();
assertNull(context.getBehaviorCommandHook());
// ## Act ##
context.setBehaviorCommandHook(new BehaviorCommandHook() {
public void hookBefore(BehaviorCommandMeta meta) {
fail();
}
public void hookFinally(BehaviorCommandMeta meta, RuntimeException cause) {
fail();
}
});
context.setBehaviorCommandHook(new BehaviorCommandHook() {
public void hookBefore(BehaviorCommandMeta meta) {
log("2");
markHere("secondBefore");
}
public void hookFinally(BehaviorCommandMeta meta, RuntimeException cause) {
log("3");
markHere("secondFinally");
}
@Override
public boolean inheritsExistingHook() {
return false;
}
});
// ## Assert ##
BehaviorCommandHook hook = context.getBehaviorCommandHook();
assertFalse(hook.inheritsExistingHook());
hook.hookBefore(null);
hook.hookFinally(null, null);
assertMarked("secondBefore");
assertMarked("secondFinally");
}
use of org.dbflute.bhv.core.BehaviorCommandMeta in project dbflute-core by dbflute.
the class CallbackContextTest method test_BehaviorCommandHook_twiceSet_inherits.
public void test_BehaviorCommandHook_twiceSet_inherits() throws Exception {
// ## Arrange ##
CallbackContext context = new CallbackContext();
assertNull(context.getBehaviorCommandHook());
// ## Act ##
context.setBehaviorCommandHook(new BehaviorCommandHook() {
public void hookBefore(BehaviorCommandMeta meta) {
log("1");
markHere("firstBefore");
}
public void hookFinally(BehaviorCommandMeta meta, RuntimeException cause) {
log("4");
markHere("firstFinally");
}
});
context.setBehaviorCommandHook(new BehaviorCommandHook() {
public void hookBefore(BehaviorCommandMeta meta) {
log("2");
markHere("secondBefore");
}
public void hookFinally(BehaviorCommandMeta meta, RuntimeException cause) {
log("3");
markHere("secondFinally");
}
@Override
public boolean inheritsExistingHook() {
return true;
}
});
// ## Assert ##
BehaviorCommandHook hook = context.getBehaviorCommandHook();
assertTrue(hook.inheritsExistingHook());
hook.hookBefore(null);
hook.hookFinally(null, null);
assertMarked("firstBefore");
assertMarked("secondBefore");
assertMarked("secondFinally");
assertMarked("firstFinally");
}
use of org.dbflute.bhv.core.BehaviorCommandMeta in project dbflute-core by dbflute.
the class CallbackContextWholeTest method setupTwoBehaviorCommandHook.
private void setupTwoBehaviorCommandHook() {
CallbackContext.setBehaviorCommandHookOnThread(new BehaviorCommandHook() {
public void hookBefore(BehaviorCommandMeta meta) {
log("firstBefore");
markHere("firstBefore");
}
public void hookFinally(BehaviorCommandMeta meta, RuntimeException cause) {
log("firstFinally");
markHere("firstFinally");
}
});
CallbackContext.setBehaviorCommandHookOnThread(new BehaviorCommandHook() {
public void hookBefore(BehaviorCommandMeta meta) {
log("secondBefore");
markHere("secondBefore");
}
public void hookFinally(BehaviorCommandMeta meta, RuntimeException cause) {
log("secondFinally");
markHere("secondFinally");
}
});
}
use of org.dbflute.bhv.core.BehaviorCommandMeta in project dbflute-core by dbflute.
the class CallbackContextTest method setupTwoBehaviorCommandHook.
private void setupTwoBehaviorCommandHook(CallbackContext context) {
context.setBehaviorCommandHook(new BehaviorCommandHook() {
public void hookBefore(BehaviorCommandMeta meta) {
markHere("firstBefore");
}
public void hookFinally(BehaviorCommandMeta meta, RuntimeException cause) {
markHere("firstFinally");
}
});
context.setBehaviorCommandHook(new BehaviorCommandHook() {
public void hookBefore(BehaviorCommandMeta meta) {
markHere("secondBefore");
}
public void hookFinally(BehaviorCommandMeta meta, RuntimeException cause) {
markHere("secondFinally");
}
});
}
use of org.dbflute.bhv.core.BehaviorCommandMeta in project dbflute-core by dbflute.
the class SelectCBExecution method doFilterExecutedSqlByCallbackFilter.
protected String doFilterExecutedSqlByCallbackFilter(String executedSql) {
final SqlStringFilter sqlStringFilter = getSqlStringFilter();
if (sqlStringFilter != null) {
final BehaviorCommandMeta meta = ResourceContext.behaviorCommand();
final String filteredSql = sqlStringFilter.filterSelectCB(meta, executedSql);
return filteredSql != null ? filteredSql : executedSql;
}
return executedSql;
}
Aggregations