openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject [openjpa] 03/03: fix broken unit test. Illegal table 'ROLES'
Date Sat, 02 Feb 2019 12:55:44 GMT
This is an automated email from the ASF dual-hosted git repository.

struberg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openjpa.git

commit 6e8c4d987fa0f2364d880f8fab4c5d85f790f538
Author: Mark Struberg <struberg@apache.org>
AuthorDate: Sat Feb 2 13:49:27 2019 +0100

    fix broken unit test. Illegal table 'ROLES'
    
    The ROLES table exists by default in some datbases.
    So it's probably better to not use it as table name in our unit test.
---
 .../org/apache/openjpa/persistence/query/Role.java |   2 +-
 .../persistence/query/TestOutOfBoundsEx.java       | 153 +++++++++++----------
 2 files changed, 78 insertions(+), 77 deletions(-)

diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/Role.java
b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/Role.java
index 6cd4eee..3ea0d45 100644
--- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/Role.java
+++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/Role.java
@@ -28,7 +28,7 @@ import javax.persistence.ManyToOne;
 import javax.persistence.Table;
 
 @Entity
-@Table(name = "roles")
+@Table(name = "rolesx")
 public class Role {
 
     @Id
diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestOutOfBoundsEx.java
b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestOutOfBoundsEx.java
index 45c414c..85d2738 100644
--- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestOutOfBoundsEx.java
+++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestOutOfBoundsEx.java
@@ -30,82 +30,83 @@ import org.apache.openjpa.persistence.QueryImpl;
 import org.apache.openjpa.persistence.test.SingleEMFTestCase;
 
 public class TestOutOfBoundsEx extends SingleEMFTestCase {
-	private EntityManager em = null;
-	private Lookup lookup;
+    private EntityManager em = null;
+    private Lookup lookup;
 
-	@Override
+    @Override
     public void setUp() throws Exception {
-		super.setUp(Lookup.class, Case.class, Role.class, ScheduledAssignment.class, ScheduleDay.class,
-        DROP_TABLES);
-		em = emf.createEntityManager();
-		insertLookups();
-	}
-
-	public void testOutOfBounds() throws Exception {
-		Calendar cal = Calendar.getInstance();
-		final Date date = cal.getTime();
-		ScheduleDay sd = insertScheduleDay(date);
-
-		Role role1 = insertJob();
-		Role role2 = insertJob();
-		Case kase1 = insertCase(sd);
-		Case kase2 = insertCase(sd);
-		insertScheduledAssignmentInCase(role1, kase2);
-
-		// simulate new web transaction on different em
-		em.close();
-		em = emf.createEntityManager();
-
-		Query query = em.createQuery("select o from Case as o" +
-				" where o.scheduleDay = :sd");
-		query.setParameter("sd", sd);
-		FetchPlan fetchPlan = ((QueryImpl) query).getFetchPlan();
-		fetchPlan.addField(Case.class, "scheduledAssignments");
-
-		//Without the changes of OJ1424, this next call would cause an
-		//ArrayIndexOutOfBoundsException.
-		List<Case> allCases = query.getResultList();
-	}
-
-	public void insertLookups() {
-		lookup = new Lookup();
-		lookup.setName("XYZ");
-		lookup.setId(1);
-		save(lookup);
-	}
-
-	public void save(Object obj) {
-		em.getTransaction().begin();
-		em.persist(obj);
-		em.getTransaction().commit();
-	}
-
-	public Role insertJob() {
-		Role role = new Role();
-		role.setLookup(lookup);
-		save(role);
-		return role;
-	}
-
-	public Case insertCase(ScheduleDay sd) throws Exception {
-		Case kase = new Case();
-		kase.setScheduleDay(sd);
-		save(kase);
-		return kase;
-	}
-
-	public void insertScheduledAssignmentInCase(Role job, Case kase) {
-		ScheduledAssignment sa = new ScheduledAssignment();
-		sa.setRole(job);
-		sa.setCase(kase);
-		sa.setScheduleDay(kase.getScheduleDay());
-		save(sa);
-	}
-
-	public ScheduleDay insertScheduleDay(Date date) {
-		ScheduleDay sd = new ScheduleDay();
-		sd.setDate(date);
-		save(sd);
-		return sd;
-	}
+        super.setUp(DROP_TABLES, Lookup.class, Case.class, Role.class,
+                ScheduledAssignment.class, ScheduleDay.class,
+                "openjpa.Log", "SQL=Trace");
+        em = emf.createEntityManager();
+        insertLookups();
+    }
+
+    public void testOutOfBounds() throws Exception {
+        Calendar cal = Calendar.getInstance();
+        final Date date = cal.getTime();
+        ScheduleDay sd = insertScheduleDay(date);
+
+        Role role1 = insertJob();
+        Role role2 = insertJob();
+        Case kase1 = insertCase(sd);
+        Case kase2 = insertCase(sd);
+        insertScheduledAssignmentInCase(role1, kase2);
+
+        // simulate new web transaction on different em
+        em.close();
+        em = emf.createEntityManager();
+
+        Query query = em.createQuery("select o from Case as o" +
+                " where o.scheduleDay = :sd");
+        query.setParameter("sd", sd);
+        FetchPlan fetchPlan = ((QueryImpl) query).getFetchPlan();
+        fetchPlan.addField(Case.class, "scheduledAssignments");
+
+        //Without the changes of OJ1424, this next call would cause an
+        //ArrayIndexOutOfBoundsException.
+        List<Case> allCases = query.getResultList();
+    }
+
+    public void insertLookups() {
+        lookup = new Lookup();
+        lookup.setName("XYZ");
+        lookup.setId(1);
+        save(lookup);
+    }
+
+    public void save(Object obj) {
+        em.getTransaction().begin();
+        em.persist(obj);
+        em.getTransaction().commit();
+    }
+
+    public Role insertJob() {
+        Role role = new Role();
+        role.setLookup(lookup);
+        save(role);
+        return role;
+    }
+
+    public Case insertCase(ScheduleDay sd) throws Exception {
+        Case kase = new Case();
+        kase.setScheduleDay(sd);
+        save(kase);
+        return kase;
+    }
+
+    public void insertScheduledAssignmentInCase(Role job, Case kase) {
+        ScheduledAssignment sa = new ScheduledAssignment();
+        sa.setRole(job);
+        sa.setCase(kase);
+        sa.setScheduleDay(kase.getScheduleDay());
+        save(sa);
+    }
+
+    public ScheduleDay insertScheduleDay(Date date) {
+        ScheduleDay sd = new ScheduleDay();
+        sd.setDate(date);
+        save(sd);
+        return sd;
+    }
 }


Mime
View raw message