Bonjour,
J'ai un souci avec Hibernate et Junit, si vous voulez je n'arrive pas à tester une méthode ça bloque ici :
Session session = getHibernateTemplate().getSessionFactory().getCurrentSession();
voilà mon code Junit
1 2 3 4 5 6 7 8 9 10 11 12 13
| public class UserDaoTests extends TestCase{
UserDao userDao = null;
@Override
protected void setUp() throws Exception {
userDao = new UserDaoImpl();
}
public void testGetAllUsers(){
userDao.getUsers();
}
} |
ça lance un exception de type NullPointerException
Mon fichier hibernate.cfg.xml est le suivant
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.password">root</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/experiments</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<mapping class="appli.domain.User"/>
</session-factory>
</hibernate-configuration> |
Merci à votre aide
Partager