MockControl sessionControl = MockControl.createControl(Session.class);
final Session session = (Session) sessionControl.getMock();
MockControl txControl = MockControl.createControl(Transaction.class);
Transaction tx = (Transaction) txControl.getMock();
sf.openSession();
sfControl.setReturnValue(session, 1);
session.beginTransaction();
sessionControl.setReturnValue(tx, 1);
session.isOpen();
sessionControl.setReturnValue(true, 1);