### Question:
SomeBean { public String logout() { FacesContext.getCurrentInstance().getExternalContext() .invalidateSession(); return "logout?faces-redirect=true"; }  void addMessage(Severity severity, String summary, String detail); String logout();  }### Answer:
@Test public void testLogout() { assertEquals("logout?faces-redirect=true", someBean.logout()); }
@Test public void testLogout() { expect(FacesContext.getCurrentInstance()).andReturn(facesContext) .once(); expect(facesContext.getExternalContext()).andReturn(externalContext) .once(); externalContext.invalidateSession(); expectLastCall().once(); PowerMock.replay(FacesContext.class); replay(facesContext); replay(externalContext); assertEquals("logout?faces-redirect=true", someBean.logout()); PowerMock.verify(FacesContext.class); verify(facesContext); verify(externalContext); }