### Question:
HttpUtil { @SuppressWarnings("unchecked") public static <T> T getSessionAttribute(final HttpSession session, final String key) { if (session != null) { return (T) session.getAttribute(key); } return null; } private  HttpUtil(); @SuppressWarnings("unchecked") static T getSessionAttribute(final HttpSession session, final String key); @SuppressWarnings("unchecked") static T getRequestAttribute(final HttpServletRequest request, final String key);  }### Answer:
@Test public void getSessionAttributeTest() { HttpSession session = mock(HttpSession.class); when(session.getAttribute("myobject")).thenReturn(new TestObject()); Assert.assertTrue(HttpUtil.getSessionAttribute(session, "myobject") instanceof TestObject); Assert.assertTrue(HttpUtil.getSessionAttribute(session, "foo") == null); }