Permalink
Browse files

cleaning up

  • Loading branch information...
1 parent 29f9976 commit 1451515f66bf7733202129ef4a17cb6ce48a5fbc meri committed Jan 16, 2012
Showing with 53 additions and 0 deletions.
  1. +53 −0 src/test/java/org/meri/jpa/simplest/DemoJPATest.java
@@ -0,0 +1,53 @@
+package org.meri.jpa.simplest;
+
+import static org.junit.Assert.assertFalse;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.persistence.Query;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.meri.jpa.AbstractTestCase;
+import org.meri.jpa.simplest.entity.Person;
+
+public class DemoJPATest extends AbstractTestCase {
+
+ private static final String CHANGELOG_LOCATION = "src/test/java/org/meri/jpa/simplest/db.changelog.xml";
+ private static EntityManagerFactory factory;
+
+ public DemoJPATest() {
+ }
+
+ @Override
+ protected String getInitialChangeLog() {
+ return CHANGELOG_LOCATION;
+ }
+
+ @Test
+ @SuppressWarnings("unchecked")
+ public void testJPA() {
+ EntityManager em = factory.createEntityManager();
+
+ Query query = em.createQuery("SELECT x FROM Person x");
+ List<Person> allUsers = query.getResultList();
+ em.close();
+
+ assertFalse(allUsers.isEmpty());
+ }
+
+ @BeforeClass
+ public static void createFactory() {
+ factory = Persistence.createEntityManagerFactory("Simplest");
+ }
+
+ @AfterClass
+ public static void closeFactory() {
+ factory.close();
+ }
+
+}

0 comments on commit 1451515

Please sign in to comment.