JcrDaoSupport extends DaoSupport { protected final Session getSession() { return getSession(this.template.isAllowCreate()); }  final void setSessionFactory(SessionFactory sessionFactory); final SessionFactory getSessionFactory(); final void setTemplate(JcrTemplate jcrTemplate); final JcrTemplate getTemplate();  }
@Test public void testGetSession() throws RepositoryException { JcrDaoSupport dao = new JcrDaoSupport() { }; expect(sessionFactory.getSession()).andReturn(session); replay(sessionFactory); replay(session); dao.setSessionFactory(sessionFactory); dao.afterPropertiesSet(); try { dao.getSession(); fail("expected exception"); } catch (IllegalStateException e) { } assertEquals(dao.getSession(true), session); }