@Test
public void testGetSession() throws RepositoryException {

    JcrDaoSupport dao = new JcrDaoSupport() {
    };
    // used for service provider
    expect(sessionFactory.getSession()).andReturn(session);
    replay(sessionFactory);
    replay(session);
    dao.setSessionFactory(sessionFactory);
    dao.afterPropertiesSet();
    try {
        dao.getSession();
        fail("expected exception");
    } catch (IllegalStateException e) {
        // it's okay
    }
    assertEquals(dao.getSession(true), session);
}