final SessionFactory sf = (SessionFactory) sfControl.getMock();
final MockControl sessionControl = MockControl.createControl(Session.class);
final Session session = (Session) sessionControl.getMock();
MockControl sfiControl = MockControl.createControl(SessionFactoryImplementor.class);
final SessionFactoryImplementor sfi = (SessionFactoryImplementor) sfiControl.getMock();
sf.openSession();
sfControl.setReturnValue(session, 1);
session.getSessionFactory();
sessionControl.setReturnValue(sfi, 6);
sfi.getTransactionManager();
sfiControl.setReturnValue(tm, 6);