use of org.apache.shiro.web.session.mgt.ServletContainerSessionManager in project shiro by apache.
the class ShiroWebModuleTest method basicInstantiation.
@Test
public void basicInstantiation() {
final ShiroModuleTest.MockRealm mockRealm = createMock(ShiroModuleTest.MockRealm.class);
ServletContext servletContext = createMock(ServletContext.class);
Injector injector = Guice.createInjector(new ShiroWebModule(servletContext) {
@Override
protected void configureShiroWeb() {
bindRealm().to(ShiroModuleTest.MockRealm.class);
expose(SessionManager.class);
}
@Provides
public ShiroModuleTest.MockRealm createRealm() {
return mockRealm;
}
});
// we're not getting a WebSecurityManager here b/c it's not exposed. There didn't seem to be a good reason to
// expose it outside of the Shiro module.
SecurityManager securityManager = injector.getInstance(SecurityManager.class);
assertNotNull(securityManager);
assertTrue(securityManager instanceof WebSecurityManager);
SessionManager sessionManager = injector.getInstance(SessionManager.class);
assertNotNull(sessionManager);
assertTrue(sessionManager instanceof ServletContainerSessionManager);
assertTrue(((DefaultWebSecurityManager) securityManager).getSessionManager() instanceof ServletContainerSessionManager);
}
Aggregations