From eaecedf328038ea646c7b55063f71b40218f3a65 Mon Sep 17 00:00:00 2001
From: Mark Struberg <struberg@apache.org>
Date: Sat, 3 Nov 2018 14:25:23 +0100
Subject: [PATCH] fix more broken tests due to lazy Id generation

---
 .../src/test/resources/META-INF/persistence.xml            | 7 +++++++
 .../jdbc/maps/m2mmapex1/TestMany2ManyMapEx1.java           | 4 +++-
 .../jdbc/maps/spec_10_1_27_ex3/TestSpec10_1_27_Ex3.java    | 4 +++-
 .../jdbc/maps/spec_10_1_27_ex8/TestSpec10_1_27_Ex8.java    | 2 ++
 .../jdbc/maps/spec_10_1_29_ex1/TestSpec10_1_29_Ex1.java    | 5 ++++-
 5 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/openjpa-examples/image-gallery/src/test/resources/META-INF/persistence.xml b/openjpa-examples/image-gallery/src/test/resources/META-INF/persistence.xml
index 19716d37e..2684c3a49 100644
--- a/openjpa-examples/image-gallery/src/test/resources/META-INF/persistence.xml
+++ b/openjpa-examples/image-gallery/src/test/resources/META-INF/persistence.xml
@@ -32,10 +32,17 @@
         <exclude-unlisted-classes>true</exclude-unlisted-classes>
         <validation-mode>CALLBACK</validation-mode>
         <properties>
+            <!--
+                this is only needed when not passing in the connection via
+                either passing in via EntityManagerFactory or
+                environment variable.
+                In our case this is already properly setup in the
+                OpenJPA parent pom.
           <property name="openjpa.ConnectionDriverName"
               value="org.apache.derby.jdbc.EmbeddedDriver" />
           <property name="openjpa.ConnectionURL"
               value="jdbc:derby:target/database/ImageDB;create=true" />
+            -->
           <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
           <property name="openjpa.DynamicEnhancementAgent" value="false"/>
 
diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/m2mmapex1/TestMany2ManyMapEx1.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/m2mmapex1/TestMany2ManyMapEx1.java
index 6872a7850..6ced5ff39 100644
--- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/m2mmapex1/TestMany2ManyMapEx1.java
+++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/m2mmapex1/TestMany2ManyMapEx1.java
@@ -114,7 +114,9 @@ public class TestMany2ManyMapEx1 extends SQLListenerTestCase {
         rs = q.getResultList();
         Map.Entry me = (Map.Entry) rs.get(0);
 
-        assertTrue(d.equals(me.getKey()));
+        Division other = (Division) me.getKey();
+        assertEquals(d.getId(), other.getId());
+        assertEquals(d.getName(), other.getName());
 
         // test navigation thru KEY
         em.clear();
diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_27_ex3/TestSpec10_1_27_Ex3.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_27_ex3/TestSpec10_1_27_Ex3.java
index f60e4e5eb..741c88796 100644
--- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_27_ex3/TestSpec10_1_27_Ex3.java
+++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_27_ex3/TestSpec10_1_27_Ex3.java
@@ -99,7 +99,9 @@ public class TestSpec10_1_27_Ex3 extends SQLListenerTestCase {
         rs = q.getResultList();
         Map.Entry me = (Map.Entry) rs.get(0);
 
-        assertTrue(d.equals(me.getKey()));
+        Division other = (Division) me.getKey();
+        assertEquals(d.getId(), other.getId());
+        assertEquals(d.getName(), other.getName());
 
         em.clear();
         query = "select KEY(e) from Company c " +
diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_27_ex8/TestSpec10_1_27_Ex8.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_27_ex8/TestSpec10_1_27_Ex8.java
index eb19c5b40..d770e2738 100644
--- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_27_ex8/TestSpec10_1_27_Ex8.java
+++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_27_ex8/TestSpec10_1_27_Ex8.java
@@ -122,7 +122,9 @@ public class TestSpec10_1_27_Ex8 extends SQLListenerTestCase {
             setCandidate(q, Company.class);
         rs = q.getResultList();
         me = (Map.Entry) rs.get(0);
+
         assertTrue(d.equals(me.getKey()));
+
         assertEquals(v.getId(), ((VicePresident) me.getValue()).getId());
 
         em.close();
diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_29_ex1/TestSpec10_1_29_Ex1.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_29_ex1/TestSpec10_1_29_Ex1.java
index 8c187525d..ebc9cf3b9 100644
--- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_29_ex1/TestSpec10_1_29_Ex1.java
+++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/maps/spec_10_1_29_ex1/TestSpec10_1_29_Ex1.java
@@ -125,7 +125,10 @@ public class TestSpec10_1_29_Ex1 extends SQLListenerTestCase {
             setCandidate(q, Company.class);
         rs = q.getResultList();
         me = (Map.Entry) rs.get(0);
-        assertTrue(d.equals(me.getKey()));
+        Division other = (Division) me.getKey();
+        assertEquals(d.getId(), other.getId());
+        assertEquals(d.getName(), other.getName());
+
         assertEquals(v.getId(), ((VicePresident) me.getValue()).getId());
 
         em.close();