### Question:
HttpGadgetContext extends GadgetContext { @Override public String getUserAgent() { String userAgent = request.getHeader("User-Agent"); if (userAgent == null) { return super.getUserAgent(); } return userAgent; } 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 testGetUserAgent() throws Exception { expect(request.getHeader("User-Agent")).andReturn("Mozilla/4.0"); replay(); GadgetContext context = new HttpGadgetContext(request); assertEquals("Mozilla/4.0", context.getUserAgent()); }