Commit 6f9d5a26 authored by Julien Durillon's avatar Julien Durillon
Browse files

avec les tests, c'est mieux\!

parent 526e199a
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fr.alma.modele.persistance;
import fr.alma.modele.noyau.IContact;
import fr.alma.modele.noyau.IProjet;
import fr.alma.modele.noyau.ITache;
import fr.alma.modele.noyau.Projet;
import fr.alma.modele.noyau.Tache;
import java.io.File;
import org.hibernate.SQLQuery;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.dialect.H2Dialect;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author judu
*/
public class BDTest {
private static char[] mdp;
private static String login;
private static String nologin;
private static String mail;
public BDTest() {
}
@BeforeClass
public static void setUpClass() throws Exception {
System.out.println("Penser à supprimer le fichier ~/test.h2.db");
mdp = new char[8];
for (int i = 0; i < mdp.length; ++i) {
mdp[i] = 'i';
}
login = "judu";
nologin = "lolilol";
mail = "judu@moi.com";
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of existeUtilisateur method, of class BD.
*/
@Test
public void testExisteUtilisateur_String() {
System.out.println("existeUtilisateur");
BD instance = new BD();
Boolean expResult = false;
Boolean result = instance.existeUtilisateur(login);
assertEquals("normalement, l'utilisateur n'existe pas", expResult, result);
// creerCompte a été testé, on peut rajouter les tests suivants :
instance.creerCompte(login, mdp, mail);
result = instance.existeUtilisateur(login);
expResult = true;
assertEquals("L'utilisateur devrait exister", expResult, result);
result = instance.existeUtilisateur(nologin);
expResult = false;
assertEquals("L'utilisateur ne devrait pas exister", expResult, result);
}
/**
* Test of existeUtilisateur method, of class BD.
*/
@Test
public void testExisteUtilisateur_String_charArr() {
System.out.println("existeUtilisateur");
BD instance = new BD();
Long expResult = null;
Long result = instance.existeUtilisateur(nologin, mdp);
assertEquals(expResult, result);
// creerCompte testé : on peut tester la suite :
instance.creerCompte(login, mdp, mail);
expResult = new Long(0);
result = instance.existeUtilisateur(login, mdp);
}
/**
* Test of getIdUtilisateur method, of class BD.
*/
@Test
public void testGetIdUtilisateur() {
System.out.println("getIdUtilisateur");
BD instance = new BD();
Long expResult = null;
Long result = instance.getIdUtilisateur(nologin);
assertEquals(expResult, result);
}
/**
* Test of creerCompte method, of class BD.
*/
@Test
public void testCreerCompte() {
String loginCreation = "loginCreation";
System.out.println("creerCompte");
BD instance = new BD();
Boolean expResult = true;
Boolean result = instance.creerCompte(loginCreation, mdp, mail);
assertEquals(expResult, result);
expResult = false;
result = instance.creerCompte(loginCreation, mdp, mail);
assertEquals(expResult, result);
}
/**
* Test of ajouterProjetBD method, of class BD.
*/
@Test
public void testAjouterProjetBD() {
System.out.println("ajouterProjetBD");
IProjet projet = new Projet("projet1", "contexte1", "notes");
Long idProjet = new Long(1);
BD instance = new BD();
Long result = instance.ajouterProjetBD(projet, idProjet);
assertNotNull(result);
}
/**
* Test of recupererProjetRacine method, of class BD.
*/
@Test
public void testRecupererProjetRacine() {
System.out.println("recupererProjetRacine");
BD instance = new BD();
IProjet expResult = null;
IProjet result = instance.recupererProjetRacine();
assertEquals(expResult, result);
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fr.alma.modele.persistance.dao.impl;
import fr.alma.modele.noyau.Utilisateur;
import fr.alma.modele.persistance.BD;
import java.util.LinkedList;
import java.util.List;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author judu
*/
public class UtilisateurDaoImplTest {
private static char[] mdp;
private static String login;
private static String nologin;
private static String mail;
public UtilisateurDaoImplTest() {
}
@BeforeClass
public static void setUpClass() throws Exception {
char[] mmm = {'i','i','i','i','i','i','i','i'};
mdp = mmm;
login = "judu2";
nologin = "lolilol";
mail = "judu@moi.com";
BD database = new BD();
database.creerCompte(login, mdp, mail);
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of recupererTout method, of class UtilisateurDaoImpl.
*/
@Test
public void testRecupererTout() {
System.out.println("recupererTout");
UtilisateurDaoImpl instance = new UtilisateurDaoImpl();
List result = instance.recupererTout();
System.out.println(result.toString());
assertTrue(result.size() > 0 );
}
/**
* Test of trouverUtilisateur method, of class UtilisateurDaoImpl.
*/
@Test
public void testTrouverUtilisateur_String() {
System.out.println("trouverUtilisateur");
UtilisateurDaoImpl instance = new UtilisateurDaoImpl();
Utilisateur expResult = new Utilisateur(login, mdp, mail);
Utilisateur result = instance.trouverUtilisateur(login);
assertEquals(expResult.getLogin(), result.getLogin());
result = instance.trouverUtilisateur("nonexistant");
assertNull(result);
}
/**
* Test of trouverUtilisateur method, of class UtilisateurDaoImpl.
*/
@Test
public void testTrouverUtilisateur_String_charArr() {
System.out.println("trouverUtilisateur");
UtilisateurDaoImpl instance = new UtilisateurDaoImpl();
Utilisateur result = instance.trouverUtilisateur(login, mdp);
assertNotNull(result);
char[] mauvaispass = {'m','a','u','v','a','i','s'};
result = instance.trouverUtilisateur(login, mauvaispass);
assertNull(result);
result = instance.trouverUtilisateur("mauvais", mdp);
}
}
\ No newline at end of file
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fr.alma.modele.serveur;
import java.util.Date;
import java.util.List;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author judu
*/
public class ConnexionServeurTest {
public ConnexionServeurTest() {
}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of creerCompte method, of class ConnexionServeur.
*/
@Test
public void testCreerCompte() {
System.out.println("creerCompte");
String login = "";
String mdp = "";
ConnexionServeur instance = new ConnexionServeur();
Boolean expResult = null;
Boolean result = instance.creerCompte(login, mdp);
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of supprimerCompte method, of class ConnexionServeur.
*/
@Test
public void testSupprimerCompte() {
System.out.println("supprimerCompte");
String login = "";
String mdp = "";
ConnexionServeur instance = new ConnexionServeur();
Boolean expResult = null;
Boolean result = instance.supprimerCompte(login, mdp);
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of connect method, of class ConnexionServeur.
*/
@Test
public void testConnect() {
System.out.println("connect");
String login = "";
String mdp = "";
ConnexionServeur instance = new ConnexionServeur();
String expResult = "";
String result = instance.connect(login, mdp);
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of disconnect method, of class ConnexionServeur.
*/
@Test
public void testDisconnect() {
System.out.println("disconnect");
ConnexionServeur instance = new ConnexionServeur();
String expResult = "";
String result = instance.disconnect();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getInfosServeur method, of class ConnexionServeur.
*/
@Test
public void testGetInfosServeur() {
System.out.println("getInfosServeur");
ConnexionServeur instance = new ConnexionServeur();
String expResult = "";
String result = instance.getInfosServeur();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of resetLog method, of class ConnexionServeur.
*/
@Test
public void testResetLog() {
System.out.println("resetLog");
ConnexionServeur instance = new ConnexionServeur();
String expResult = "";
String result = instance.resetLog();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of listeProjetsServeur method, of class ConnexionServeur.
*/
@Test
public void testListeProjetsServeur_Date() {
System.out.println("listeProjetsServeur");
Date date = null;
ConnexionServeur instance = new ConnexionServeur();
List expResult = null;
List result = instance.listeProjetsServeur(date);
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of listeProjetsServeur method, of class ConnexionServeur.
*/
@Test
public void testListeProjetsServeur_0args() {
System.out.println("listeProjetsServeur");
ConnexionServeur instance = new ConnexionServeur();
List expResult = null;
List result = instance.listeProjetsServeur();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getISynchronisation method, of class ConnexionServeur.
*/
@Test
public void testGetISynchronisation() {
System.out.println("getISynchronisation");
ConnexionServeur instance = new ConnexionServeur();
ISynchronisation expResult = null;
ISynchronisation result = instance.getISynchronisation();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of setISynchronisation method, of class ConnexionServeur.
*/
@Test
public void testSetISynchronisation() {
System.out.println("setISynchronisation");
ISynchronisation iSynchronisation = null;
ConnexionServeur instance = new ConnexionServeur();
instance.setISynchronisation(iSynchronisation);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment