@Test
public void testMkdDirWithUnauthorizedSession() throws Exception {

    Session session = mock(Session.class);
    when(session.nodeExists(anyString())).thenReturn(false);
    when(session.getWorkspace()).thenReturn(admin.getWorkspace());
    JcrPackageManagerImpl jcrPackageManager = new JcrPackageManagerImpl(session, new String[0]);
    String path = "/etc/packages";
    try {
        jcrPackageManager.mkdir(path, true);
        fail("this should have thrown RepositoryException as the session always tells nodes don't exist");
    }
    catch (RepositoryException e) {
        // everything it's ok
    }
}