use of org.dbflute.bhv.core.BehaviorCommandHook in project dbflute-core by dbflute.
the class CallbackContextTest method test_BehaviorCommandHook_threeSet_inherits.
// -----------------------------------------------------
// Three Set
// ---------
public void test_BehaviorCommandHook_threeSet_inherits() throws Exception {
// ## Arrange ##
CallbackContext context = new CallbackContext();
assertNull(context.getBehaviorCommandHook());
// ## Act ##
setupThreeBehaviorCommandHook(context);
// ## Assert ##
BehaviorCommandHook hook = context.getBehaviorCommandHook();
assertTrue(hook.inheritsExistingHook());
hook.hookBefore(null);
hook.hookFinally(null, null);
assertMarked("firstBefore");
assertMarked("secondBefore");
assertMarked("thirdBefore");
assertMarked("thirdFinally");
assertMarked("secondFinally");
assertMarked("firstFinally");
}
use of org.dbflute.bhv.core.BehaviorCommandHook in project dbflute-core by dbflute.
the class CallbackContextTest method test_BehaviorCommandHook_twoSet_noInherits.
// -----------------------------------------------------
// No Inherits
// -----------
public void test_BehaviorCommandHook_twoSet_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) {
markHere("secondBefore");
}
public void hookFinally(BehaviorCommandMeta meta, RuntimeException cause) {
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.BehaviorCommandHook in project dbflute-core by dbflute.
the class CallbackContextTest method test_BehaviorCommandHook_threeSet_terminateLast.
public void test_BehaviorCommandHook_threeSet_terminateLast() throws Exception {
// ## Arrange ##
CallbackContext context = new CallbackContext();
assertNull(context.getBehaviorCommandHook());
setupThreeBehaviorCommandHook(context);
assertNotNull(context.getBehaviorCommandHook());
assertTrue(context.getBehaviorCommandHook() instanceof InheritableBehaviorCommandHook);
assertEquals(3, ((InheritableBehaviorCommandHook) context.getBehaviorCommandHook()).countManagedHook());
// ## Act ##
context.terminateLastBehaviorCommandHook();
// ## Assert ##
BehaviorCommandHook hook = context.getBehaviorCommandHook();
assertNotNull(hook);
hook.hookBefore(null);
hook.hookFinally(null, null);
assertMarked("firstBefore");
assertMarked("secondBefore");
assertMarked("secondFinally");
assertMarked("firstFinally");
assertTrue(context.getBehaviorCommandHook() instanceof InheritableBehaviorCommandHook);
}
Aggregations