### Question:
HttpGadgetContext extends GadgetContext { @Override public SecurityToken getToken() { return new AuthInfo(request).getSecurityToken(); } HttpGadgetContext(HttpServletRequest request); @Override String getParameter(String name); @Override String getContainer(); @Override String getHost(); @Override String getUserIp(); @Override boolean getDebug(); @Override boolean getIgnoreCache(); @Override Locale getLocale(); @Override int getModuleId(); @Override RenderingContext getRenderingContext(); @Override SecurityToken getToken(); @Override Uri getUrl(); @Override UserPrefs getUserPrefs(); @Override String getView(); @Override String getUserAgent(); static final String USERPREF_PARAM_PREFIX; }### Answer:
@Test public void testGetSecurityToken() throws Exception { SecurityToken expected = new AnonymousSecurityToken(); expect(request.getAttribute(AuthInfo.Attribute.SECURITY_TOKEN.getId())).andReturn(expected); replay(); GadgetContext context = new HttpGadgetContext(request); assertEquals(expected, context.getToken()); }