2020-04-29 19:14:18 +02:00
package database ;
import java.sql.Connection ;
import java.sql.DriverManager ;
import java.sql.SQLException ;
import org.junit.Assert ;
import org.junit.jupiter.api.AfterEach ;
import org.junit.jupiter.api.BeforeEach ;
import org.junit.jupiter.api.Test ;
public class TestDatabse {
Table t ;
@BeforeEach
private void initialize ( ) {
2020-05-08 17:00:32 +02:00
System . out . println ( " =====Initialisation du test====== " ) ;
2020-04-29 19:14:18 +02:00
t = new Table ( " Table de Test " ) ;
}
@AfterEach
private void free ( ) {
2020-05-04 13:41:10 +02:00
System . gc ( ) ;
2020-05-08 17:00:32 +02:00
System . out . println ( " ===========Fin du test=========== \ n \ n \ n " ) ;
2020-04-29 19:14:18 +02:00
}
@Test
2020-05-04 13:41:10 +02:00
void testDBConnexion ( ) {
2020-04-29 19:14:18 +02:00
try ( Connection connection = DriverManager . getConnection ( " jdbc:postgresql://localhost:5432/ShadowHunterDatabase " , " shManager " , " shadowhunter1234 " ) ) { //notre utilisateur que l'on utilisera (:
System . out . println ( " Connected to PostgreSQL database! " ) ;
} catch ( SQLException e ) {
System . out . println ( " Connection failure. " ) ;
e . printStackTrace ( ) ;
}
}
@Test
2020-05-04 13:41:10 +02:00
void getEntireTableCartesLumiere ( ) {
System . out . println ( " Test getEntireTableCartesLumiere " ) ;
2020-05-06 15:40:34 +02:00
t . fillList ( QueryGenerator . AllFrom ( " CartesLumiere " ) ) ;
2020-04-29 19:14:18 +02:00
Assert . assertFalse ( t . isEmpty ( ) ) ;
}
2020-05-04 13:41:10 +02:00
@Test
void getEntireTableCartesTenebre ( ) {
System . out . println ( " Test getEntireTableCartesTenebre " ) ;
2020-05-06 15:40:34 +02:00
t . fillList ( QueryGenerator . AllFrom ( " CartesTenebre " ) ) ;
2020-05-04 13:41:10 +02:00
Assert . assertFalse ( t . isEmpty ( ) ) ;
}
@Test
void getEntireTableCartesVision ( ) {
System . out . println ( " Test getEntireTableCartesVision " ) ;
2020-05-06 15:40:34 +02:00
t . fillList ( QueryGenerator . AllFrom ( " CartesVision " ) ) ;
2020-05-04 13:41:10 +02:00
Assert . assertFalse ( t . isEmpty ( ) ) ;
}
@Test
void getEntireTableCartesPersonnage ( ) {
System . out . println ( " Test getEntireTableCartesPersonnage " ) ;
2020-05-06 15:40:34 +02:00
t . fillList ( QueryGenerator . AllFrom ( " CartesPersonnage " ) ) ;
2020-05-04 13:41:10 +02:00
Assert . assertFalse ( t . isEmpty ( ) ) ;
}
@Test
void getEntireTableCartesDos ( ) {
System . out . println ( " Test getEntireTableCartesDos " ) ;
2020-05-06 15:40:34 +02:00
t . fillList ( QueryGenerator . AllFrom ( " CartesDos " ) ) ;
2020-05-04 13:41:10 +02:00
Assert . assertFalse ( t . isEmpty ( ) ) ;
}
@Test
void getEntireTableCartesAll ( ) {
System . out . println ( " Test getEntireTableCartesAll " ) ;
2020-05-06 15:40:34 +02:00
t . fillList ( QueryGenerator . AllFrom ( " CartesAll " ) ) ;
2020-05-04 13:41:10 +02:00
Assert . assertFalse ( t . isEmpty ( ) ) ;
}
2020-04-29 19:14:18 +02:00
}