If I add the following extra lines in the test

                expect(mockRequest.getCookies()).andReturn(null);
                expect(mockRequest.getContextPath()).andReturn("/");

                replay(mockRequest);

the error becomes 

java.lang.NullPointerException
        at
org.apache.shiro.web.session.ServletContainerSessionManager.createSession(ServletContainerSessionManager.java:95)
        at
org.apache.shiro.session.mgt.AbstractSessionManager.start(AbstractSessionManager.java:115)
        at
org.apache.shiro.session.mgt.AbstractSessionManager.start(AbstractSessionManager.java:111)
        at
org.apache.shiro.mgt.SessionsSecurityManager.start(SessionsSecurityManager.java:274)
        at
org.apache.shiro.subject.DelegatingSubject.getSession(DelegatingSubject.java:284)
        at
org.apache.shiro.subject.DelegatingSubject.getSession(DelegatingSubject.java:273)
        at
org.apache.shiro.mgt.SessionSubjectBinder.bindToSession(SessionSubjectBinder.java:87)
        at
org.apache.shiro.mgt.SessionSubjectBinder.bind(SessionSubjectBinder.java:81)
        at
org.apache.shiro.mgt.DefaultSecurityManager.bind(DefaultSecurityManager.java:288)
        at
org.apache.shiro.mgt.DefaultSecurityManager.login(DefaultSecurityManager.java:373)

Is there anything required to be setup before executing login in web env?

Many thanks,


Neo Anderson wrote:
> 
> 
> 
> I follow the example of  WebRememberMeManagerTest.java to setup mock web
> environment, as below:
> 
>               HttpServletRequest mockRequest =
> createNiceMock(HttpServletRequest.class);
>               WebUtils.bind(mockRequest);
>               HttpServletResponse mockResponse =
> createNiceMock(HttpServletResponse.class);
>               WebUtils.bind(mockResponse);
> 
>               securityService = (IAuthentication)
> configurator.createService(SecurityService.SHIRO_AUTH_SERVICE);
>               Boolean isSuccessful = 
> securityService.login("[email protected]", "u1");
> 
> 
> 

-- 
View this message in context: 
http://n2.nabble.com/missing-behavior-definition-for-the-preceeding-method-call-getCookies-tp3566719p3566740.html
Sent from the Shiro User mailing list archive at Nabble.com.

Reply via email to