You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by Les Hazlewood <lh...@apache.org> on 2009/09/10 17:02:29 UTC

Re: java.lang.IllegalStateException: missing behavior definition for the preceeding method call getRemoteHost()

Hi Neo,

Please update to the latest version of Shiro from SVN.  The thread
binding logic has been cleaned up a bit lately and the latest
DefaultWebSecurityManagerTest class shows how to create web subject
instances properly (see the newSubject helper method).

Regards,

Les

On Thu, Sep 10, 2009 at 7:04 AM, Neo Anderson
<ja...@yahoo.co.uk> wrote:
>
> When executing my own test I encounter a problem saying
> "java.lang.IllegalStateException: missing behavior definition for the
> preceeding method call getRemoteHost()." The example I follow to do my test
> is DefaultWebSecurityManagerTest.java. What I want to do is to test login
> after web env setup. The steps I use is as follow:
>
>                request = createNiceMock(HttpServletRequest.class);
>                response = createNiceMock(HttpServletResponse.class);
>
>                WebUtils.bindInetAddressToThread(request);
>                expect(this.request.getRemoteHost()).andReturn(null); // error goes wrong
> here
>                WebUtils.bind(request);
>                WebUtils.bind(response);
>                ThreadContext.bind(securityManager);// security manager already been setup
>                ThreadContext.bind(securityManager.getSubject());
>
> I've checking the output of WebUtils.java that the method getInetAddress
> does exactly return null value. So I am a bit confused what extra steps do I
> need to configure to setup mock web environment?
>
> stacktrace is as below:
>
> java.lang.IllegalStateException: missing behavior definition for the
> preceeding method call getRemoteHost()
>        at
> org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:30)
>        at
> org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:61)
>        at $Proxy15.getRemoteHost(Unknown Source)
>        at sample.web.MockWebEnvironment.bind(MockWebEnvironment.java:25)
>        at
> sample.security.shiro.SecurityServiceTest.setUp(SecurityServiceTest.java:47)
>
>
>
>
>
>
>
>
> --
> View this message in context: http://n2.nabble.com/java-lang-IllegalStateException-missing-behavior-definition-for-the-preceeding-method-call-getRemote-tp3617074p3617074.html
> Sent from the Shiro User mailing list archive at Nabble.com.
>