82 lines
2.1 KiB
Java
Raw Normal View History

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() {
System.out.println("=====Initialisation du test=====");
t = new Table("Table de Test");
}
@AfterEach
private void free() {
2020-05-04 13:41:10 +02:00
System.gc();
System.out.println("=====Fin du test=====\n\n\n");
}
@Test
2020-05-04 13:41:10 +02:00
void testDBConnexion() {
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"));
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());
}
}