2012. 7. 4. 11:19 IT

증상 : 

Spring의 SpringJUnit4ClassRunner 클래스를 이용하여 Session Scope로 정의한 Bean을 테스트하려고 할때 

아래와 같은 에러가 발생함.


java.lang.IllegalStateException : No Scope registered for scope 'session' 


solution : session scope을 처리하는 bean을 SimpleThreadScope 으로 바꿔치기하면 됨 


test용 context.xml 에 다음을 추가. 


<bean class="org.springframework.beans.factory.config.CustomScopeConfigurer">
    <property name="scopes">
        <map>
            <entry key="session">
                <bean class="org.springframework.context.support.SimpleThreadScope"/>
            </entry>
        </map>
    </property>
</bean>


reference : http://blog.solidcraft.eu/2011/04/how-to-test-spring-session-scoped-beans.html



posted by smplnote