Bonjour à tous,
Ma question est assez large, car elle peut remettre en cause l'architecture que j'ai défini pour mon projet.
Voilà, j'ai un entity bean nommé Abonnement dans un package Entity. Dans cet entity bean, j'ai une méthode createAbonnement, qui, avec une EntityManager, s'occupe de créer un abonnement.
D'autre part, j'ai une session bean nommée Facade dans un package Session. C'est un stateless Remote. Et j'y ai implémenté une méthode qui appelle createAbonnement, du type :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 @PersistenceContext EntityManager em; public boolean createAbonnement( Integer abo_statut_1, Integer abo_sem_id_1, Date abo_date_1, Integer abo_statut_2, ){ Abonnement abo = new Abonnement(); abo.setAbo_statut_1(abo_statut_1); abo.setAbo_sem_id_1(abo_sem_id_1); abo.setAbo_date_1(abo_date_1); try{ em.persist(abo); return true; }catch (Exception e){ return false; } }
Et enfin, j'ai un JUnit qui possède ce test :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 public boolean createAbonnementStats(){ Date date = new Date(); Abonnement abo = new Abonnement(); boolean bool = abo.createAbonnement(1, 1, date, 2); return bool; }
J'ai tout vérifié, et je ne vois pas d'erreurs, alors que mon JUnit échoue à tout les coups.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 public void testCreateAbonnement() throws RemoteException, NamingException{ Facade remote = getContext(); boolean bool = remote.createAbonnementStats(); assertEquals(bool, true); }
Quelqu'un a une idée?
Peut-être que EntityManager ne s'emploie pas dans un EntityBean?
Je dis ça, parce qu'auparavant j'ai mis createAbonnement dans une Session Bean Stateless Remote, et ça a marché...![]()
Partager