/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package dao; import com.tecgraf.dao.FacadeJPA; import java.util.List; import negocio.Aluno; import negocio.Disciplina; 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 42071020585 */ public class AlunoDAOTest { //***tem q ter static FacadeJPA facJPA; public AlunoDAOTest() { } @BeforeClass public static void setUpClass() throws Exception { //***tem q ter String persistUnitStr = "ExemploAulaPU"; facJPA = FacadeJPA.getInstance(persistUnitStr); } // testar tudo o que a gente precisa antes da classe// @AfterClass public static void tearDownClass() throws Exception { //***tem q ter // shutdown Facade JPA System.out.println("\n"); facJPA.shutdown(); } @Before public void setUp() { } @Test public void findByMatriculaTest() { Aluno a = new Aluno (); Aluno b; AlunoDAO aDao = AlunoDAO.getInstance(facJPA); //Testa existência da matrícula a.setMatricula("11111"); b= aDao.findByMatricula(a.getMatricula()); assertEquals(a.getMatricula(), b.getMatricula()); //Testa inexistência da matrícula a.setMatricula("999999"); b= aDao.findByMatricula(a.getMatricula()); assertNull(b); } /** * Teste do método findByMatricula, da classe AlunoDAO. */ @Test public void findAllDisciplinasTest() { List ld; AlunoDAO aDao = AlunoDAO.getInstance(facJPA); // Testa matrícula existente ld = aDao.findAllDisciplinas("11111"); assertNotNull(ld); System.out.println(ld); } @After public void tearDown() { } }