Skip to content

Instantly share code, notes, and snippets.

@altuga
Last active June 13, 2019 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save altuga/5e47b4550b7c29ab79d683af08df2246 to your computer and use it in GitHub Desktop.
Save altuga/5e47b4550b7c29ab79d683af08df2246 to your computer and use it in GitHub Desktop.
import com.airhacks.ping.boundary.Flight;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
/**
*
* @author altuga
*/
public class FlightIT {
private EntityManager entityManager;
private EntityTransaction tx;
@Before
public void initEM() {
this.entityManager =
Persistence.
createEntityManagerFactory("it").
createEntityManager();
this.tx = this.entityManager.getTransaction();
}
@Test
public void crudTest() {
Flight flight = new Flight("new flight", 2) ;
this.tx.begin();
this.entityManager.persist(flight);
this.tx.commit();
List<Flight> flightList = this.entityManager.
createNamedQuery("all", Flight.class).getResultList();
Assert.assertFalse(flightList.isEmpty());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment