use of org.dbflute.bhv.core.BehaviorCommandHook in project dbflute-core by dbflute.
the class CallbackContextTest method test_BehaviorCommandHook_twoSet_terminateLast.
public void test_BehaviorCommandHook_twoSet_terminateLast() throws Exception {
// ## Arrange ##
CallbackContext context = new CallbackContext();
assertNull(context.getBehaviorCommandHook());
setupTwoBehaviorCommandHook(context);
assertNotNull(context.getBehaviorCommandHook());
assertTrue(context.getBehaviorCommandHook() instanceof InheritableBehaviorCommandHook);
assertEquals(2, ((InheritableBehaviorCommandHook) context.getBehaviorCommandHook()).countManagedHook());
// ## Act ##
context.terminateLastBehaviorCommandHook();
// ## Assert ##
BehaviorCommandHook hook = context.getBehaviorCommandHook();
assertNotNull(hook);
hook.hookBefore(null);
hook.hookFinally(null, null);
assertMarked("firstBefore");
assertMarked("firstFinally");
assertFalse(context.getBehaviorCommandHook() instanceof InheritableBehaviorCommandHook);
}
use of org.dbflute.bhv.core.BehaviorCommandHook 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.BehaviorCommandHook in project dbflute-core by dbflute.
the class CallbackContextTest method test_BehaviorCommandHook_twoSet_inherits.
// ===================================================================================
// BehaviorCommandHook
// ===================
// -----------------------------------------------------
// Two Set
// -------
public void test_BehaviorCommandHook_twoSet_inherits() throws Exception {
// ## Arrange ##
CallbackContext context = new CallbackContext();
assertNull(context.getBehaviorCommandHook());
// ## Act ##
setupTwoBehaviorCommandHook(context);
// ## Assert ##
BehaviorCommandHook hook = context.getBehaviorCommandHook();
assertTrue(hook.inheritsExistingHook());
hook.hookBefore(null);
hook.hookFinally(null, null);
assertMarked("firstBefore");
assertMarked("secondBefore");
assertMarked("secondFinally");
assertMarked("firstFinally");
context.terminateLastBehaviorCommandHook();
assertNotNull(context.getBehaviorCommandHook());
context.terminateLastBehaviorCommandHook();
assertNull(context.getBehaviorCommandHook());
}
use of org.dbflute.bhv.core.BehaviorCommandHook in project dbflute-core by dbflute.
the class CallbackContextWholeTest method test_BehaviorCommandHook_whole_clear.
// -----------------------------------------------------
// Clear
// -----
public void test_BehaviorCommandHook_whole_clear() throws Exception {
// ## Arrange ##
// ## Act ##
setupTwoBehaviorCommandHook();
// ## Assert ##
BehaviorCommandHook hook = CallbackContext.getCallbackContextOnThread().getBehaviorCommandHook();
assertTrue(hook.inheritsExistingHook());
hook.hookBefore(null);
hook.hookFinally(null, null);
assertMarked("firstBefore");
assertMarked("secondBefore");
assertMarked("secondFinally");
assertMarked("firstFinally");
CallbackContext.clearBehaviorCommandHookOnThread();
assertNull(CallbackContext.getCallbackContextOnThread());
}
use of org.dbflute.bhv.core.BehaviorCommandHook in project dbflute-core by dbflute.
the class CallbackContextTest method setupThreeBehaviorCommandHook.
private void setupThreeBehaviorCommandHook(CallbackContext context) {
setupTwoBehaviorCommandHook(context);
context.setBehaviorCommandHook(new BehaviorCommandHook() {
public void hookBefore(BehaviorCommandMeta meta) {
markHere("thirdBefore");
}
public void hookFinally(BehaviorCommandMeta meta, RuntimeException cause) {
markHere("thirdFinally");
}
});
}
Aggregations