Hi,
I am trying to mock Hibernate' SessionFactory with PowerMock. In the
code that I am working on, the SessionFactory is built in the Dao
object constructor. I am doing something lke this :
PowerMock.suppress(PowerMock.constructor(Dao.class));
Dao dao = new MyDao();
SessionFactory sessionFactory =
PowerMock.createMock(SessionFactory.class);
Whitebox.setInternalState(dao, "sessionFactory", sessionFactory);
to stub out the code
public class MyDao extends Dao {}
public class Dao {
public Dao() {
this.sessionFactory = new
Configuration().configure().buildSessionFactory();
}
private SessionFactory sessionFactory;
}
Is this the right approach to stub this method? If it is, then I am
having problems with PowerMock 1.3.7 which uses javaassist v3.10 and
Hibernate 3.5 which uses javaassist v309. I am a mismatched class
version exception when I try to suppress the constructor. I am looking
at an earlier PowerMock release but if there is any way I can resolve
this issue without using an earlier version, please let me know.
Kartik
--
You received this message because you are subscribed to the Google Groups "PowerMock" group.
To post to this group, send email to
powe...@googlegroups.com.
To unsubscribe from this group, send email to
powermock+...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/powermock?hl=en.