I have some problem with wirint testcase for my JSF app. So i want to test my logout method:

```
            FacesContext context = EasyMock.createMock(FacesContext.class);
            String userName = "testUserName";
            HttpSession session = EasyMock.createMock(HttpSession.class);
            ExternalContext ext = EasyMock.createMock(ExternalContext.class);
            EasyMock.expect(ext.getSession(true)).andReturn(session);
            EasyMock.expect(context.getExternalContext()).andReturn(ext).times(2);
            context.getExternalContext().invalidateSession();
            EasyMock.expectLastCall().once();           

            EasyMock.replay(context);
            EasyMock.replay(ext);
            EasyMock.replay(session);

            loginForm = new LoginForm();
            loginForm.setUserName(userName);
            String expected = "login";
            String actual = loginForm.logout();
            context.release();

            Assert.assertEquals(expected, actual);
            EasyMock.verify(context);
            EasyMock.verify(ext);
            EasyMock.verify(session);

```

My logout method is:

```
    public String logout() {
        FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
        return "/authentication/login.xhtml?faces-redirect=true";
    }

```

My problem is that i got a nullpointer exception here:
EasyMock.expectLastCall().once()
How should it be properly tested? I guess it is something with the mocks but i couldnt find a solution, how could i mock properly the FacesContext in this case