Search in sources :

Example 1 with MockOutsideSqlContext

use of org.dbflute.mock.MockOutsideSqlContext in project dbflute-core by dbflute.

the class BehaviorCommandInvokerTest method test_clearContext.

public void test_clearContext() {
    // ## Arrange ##
    BehaviorCommandInvoker invoker = new BehaviorCommandInvoker();
    OutsideSqlContext.setOutsideSqlContextOnThread(new MockOutsideSqlContext());
    FetchAssistContext.setFetchBeanOnThread(new MockConditionBean());
    ConditionBeanContext.setConditionBeanOnThread(new MockConditionBean());
    ConditionBeanContext.setEntityRowHandlerOnThread(new EntityRowHandler<Entity>() {

        public void handle(Entity entity) {
        }
    });
    InternalMapContext.setObject("dummy", new Object());
    ResourceContext.setResourceContextOnThread(new ResourceContext());
    assertTrue(OutsideSqlContext.isExistOutsideSqlContextOnThread());
    assertTrue(FetchAssistContext.isExistFetchNarrowingBeanOnThread());
    assertTrue(ConditionBeanContext.isExistConditionBeanOnThread());
    assertTrue(ConditionBeanContext.isExistEntityRowHandlerOnThread());
    assertTrue(InternalMapContext.isExistInternalMapContextOnThread());
    assertTrue(ResourceContext.isExistResourceContextOnThread());
    // ## Act ##
    invoker.clearAllCurrentContext();
    // ## Assert ##
    assertFalse(OutsideSqlContext.isExistOutsideSqlContextOnThread());
    assertFalse(FetchAssistContext.isExistFetchNarrowingBeanOnThread());
    assertFalse(ConditionBeanContext.isExistConditionBeanOnThread());
    assertFalse(ConditionBeanContext.isExistEntityRowHandlerOnThread());
    assertFalse(InternalMapContext.isExistInternalMapContextOnThread());
    assertFalse(ResourceContext.isExistResourceContextOnThread());
}
Also used : Entity(org.dbflute.Entity) MockOutsideSqlContext(org.dbflute.mock.MockOutsideSqlContext) ResourceContext(org.dbflute.bhv.core.context.ResourceContext) MockConditionBean(org.dbflute.mock.MockConditionBean)

Aggregations

Entity (org.dbflute.Entity)1 ResourceContext (org.dbflute.bhv.core.context.ResourceContext)1 MockConditionBean (org.dbflute.mock.MockConditionBean)1 MockOutsideSqlContext (org.dbflute.mock.MockOutsideSqlContext)1