### Question:
BackgroundServletRequestWrapper extends HttpServletRequestWrapper { @Override public HttpSession getSession(boolean create) { if (create) { throw new UnsupportedOperationException("Cannot create session: This is a background servlet request."); } return null; } BackgroundServletRequestWrapper(HttpServletRequest request); @Override HttpSession getSession(boolean create);  }### Answer:
@Test(expected = UnsupportedOperationException.class) public void testPotentialCreationOfSessionYieldsException() { testee.getSession(); }
@Test(expected = UnsupportedOperationException.class) public void testExplicitCreationOfSessionYieldsException() { testee.getSession(true); }