/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package sl314.test;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
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.*;
import sl314.persistencia.League;
//import sl314.persistencia.control.LeagueJpaController;

/**
 *
 * @author juanmanuel
 */
public class PersistenciaTest {

   //private LeagueJpaController control;
    private static EntityManagerFactory factory;
    private static EntityManager em;
    private  League league;

    @BeforeClass
    public static void setUpClass() {
        factory = Persistence.createEntityManagerFactory("SoccerPU");
        em = factory.createEntityManager();

    }

    @AfterClass
    public static void tearDownClass() {
    }

    @Before
    public void setUp() {
        league=new League();
        league.setName("Liga MX");
        league.setYear(2000);
    }

    @After
    public void tearDown() {
    }

    // TODO add test methods here.
    // The methods must be annotated with annotation @Test. For example:
    //
    @Test
    public void TestCreate() {
        try {
            EntityTransaction etx = em.getTransaction();
            
            etx.begin();
            em.persist(league);
            etx.commit();
            em.close();
        } catch (Exception ex) {
            ex.printStackTrace();
        }

    }
}

@@ -198,16 +198,44 @@
 4.test;%0A
+import java.util.Properties;
 %0Aimport 
@@ -765,38 +765,32 @@
 ol;%0A    private 
-static
  EntityManagerFa
@@ -816,22 +816,16 @@
 private 
-static
  EntityM
@@ -931,223 +931,975 @@
     
-factory = Persistence.createEntityManagerFactory(%22SoccerPU%22);%0A        em = factory.createEntityManager(
+%0A%0A    %7D%0A%0A    @AfterClass%0A    public static void tearDownClass() %7B%0A    %7D%0A%0A    @Before%0A    public void setUp() %7B%0A       %0A        Properties props = new Properties();%0A        props.put(%22javax.persistence.transactionType%22, %22RESOURCE_LOCAL%22);%0A        props.put(%22javax.persistence.jtaDataSource%22, %22%22);%0A        props.put(%22javax.persistence.nonJtaDataSource%22, %22%22);%0A        props.put(%22eclipselink.jdbc.driver%22, %22com.mysql.jdbc.Driver%22
 );%0A
-%0A
     
-%7D%0A%0A
     
-@AfterClass%0A    public static void tearDownClass() %7B%0A    %7D%0A%0A    @Before%0A    public void setUp() %7B
+props.put(%22eclipselink.jdbc.url%22, %22jdbc:mysql://localhost:3306/mydb%22);%0A        props.put(%22eclipselink.jdbc.user%22, %22root%22);%0A        props.put(%22eclipselink.jdbc.password%22, %22Semeolvid0%22);%0A        //esta propiedad es para 'dropear' tablas antes de correr la prueba unitaria%0A        //props.put(%22eclipselink.ddl-generation%22, %22drop-and-create-tables%22);%0A        props.put(%22eclipselink.logging.level%22, %22INFO%22);%0A        factory = Persistence.createEntityManagerFactory(%22SoccerPU%22,props);%0A        em = factory.createEntityManager();%0A        
 %0A   
@@ -2439,26 +2439,69 @@
     
-ex.printStackTrace
+System.err.println(ex.getMessage());%0A            etx.rollback
 ();%0A

Update PersistenciaTest.java