ShiroAuthenticatingThriftInterceptor implements MethodInterceptor { @Override public Object invoke(MethodInvocation invocation) throws Throwable { checkState(initialized); Subject subject = subjectProvider.get(); if (subject.isAuthenticated()) { return invocation.proceed(); } else { throw new UnauthenticatedException(); } } ShiroAuthenticatingThriftInterceptor(); @Override Object invoke(MethodInvocation invocation);  }
@Test(expected = UnauthenticatedException.class) public void testInvokeNotAuthenticated() throws Throwable { expect(subject.isAuthenticated()).andReturn(false); replayAndInitialize(); interceptor.invoke(methodInvocation); }
@Test public void testInvokeAuthenticated() throws Throwable { Response response = Responses.ok(); expect(subject.isAuthenticated()).andReturn(true); expect(methodInvocation.proceed()).andReturn(response); replayAndInitialize(); assertSame(response, interceptor.invoke(methodInvocation)); }