AmbariSessionManager { public void setAttribute(String name, Object value) { HttpSession session = getHttpSession(); if (session != null) { session.setAttribute(name, value); } }  String getCurrentSessionId(); String getSessionCookie(); void setAttribute(String name, Object value); Object getAttribute(String name); void removeAttribute(String name);  }
@Test public void testSetAttribute() throws Exception { HttpSession session = createNiceMock(HttpSession.class); AmbariSessionManager sessionManager = createMockBuilder(AmbariSessionManager.class).addMockedMethod("getHttpSession").createMock(); expect(sessionManager.getHttpSession()).andReturn(session); session.setAttribute("foo", "bar"); replay(session, sessionManager); sessionManager.setAttribute("foo", "bar"); verify(session, sessionManager); }