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