@Test
public void testImpersonate() throws Exception {

    Session delegate = mock(Session.class);
    SessionFacade<Session> facade = getFacade(delegate);
    SimpleCredentials credentials = new SimpleCredentials("foo", "bar".toCharArray());
    JackrabbitSession jackSession = mock(JackrabbitSession.class);
    when(delegate.impersonate(credentials)).thenReturn(jackSession);
    assertNull("some other credentials should impersonate null",
            facade.impersonate(new SimpleCredentials("bar", "foo".toCharArray())));
    assertTrue("jackrabbit session impersonation should work",
            facade.impersonate(credentials) instanceof JackrabbitSession);
}