### Question:
HttpGadgetContext extends GadgetContext { @Override public String getUserIp() { String ip = request.getRemoteAddr(); return ip == null ? super.getUserIp() : ip; } HttpGadgetContext(HttpServletRequest request); @Override String getParameter(String name); @Override String getContainer(); @Override String getHost(); @Override String getHostSchema(); @Override String getUserIp(); @Override boolean getDebug(); @Override boolean getIgnoreCache(); @Override Locale getLocale(); @Override long getModuleId(); @Override RenderingContext getRenderingContext(); @Override SecurityToken getToken(); @Override Uri getUrl(); @Override UserPrefs getUserPrefs(); @Override String getView(); @Override String getUserAgent(); @Override String getRepository(); @Override String getReferer(); static final String USERPREF_PARAM_PREFIX; }### Answer:
@Test public void testGetUserIp() { expect(request.getRemoteAddr()).andReturn("2.3.4.5"); replay(); GadgetContext context = new HttpGadgetContext(request); assertEquals("2.3.4.5", context.getUserIp()); }