This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new f93ea15  [OPENJPA-2828] Fix method equals() (#72)
f93ea15 is described below

commit f93ea15745531838caf87022424604044302e95b
Author: Simone <[email protected]>
AuthorDate: Tue Sep 22 15:11:24 2020 +0200

    [OPENJPA-2828] Fix method equals() (#72)
---
 .../org/apache/openjpa/conf/Specification.java     |  4 +-
 .../openjpa/conf/SpecificationAdditionalTests.java | 81 ++++++++++++++++++++++
 2 files changed, 83 insertions(+), 2 deletions(-)

diff --git 
a/openjpa-kernel/src/main/java/org/apache/openjpa/conf/Specification.java 
b/openjpa-kernel/src/main/java/org/apache/openjpa/conf/Specification.java
index d167716..c73a9bb 100644
--- a/openjpa-kernel/src/main/java/org/apache/openjpa/conf/Specification.java
+++ b/openjpa-kernel/src/main/java/org/apache/openjpa/conf/Specification.java
@@ -94,8 +94,8 @@ public class Specification {
         if (other == null || !this.getClass().isInstance(other))
             return false;
         Specification that = (Specification)other;
-        return Objects.equals(_name, this._name) && _major == that._major
-            && Objects.equals(_minor, this._minor);
+        return Objects.equals(_name, that._name) && _major == that._major
+            && Objects.equals(_minor, that._minor);
     }
 
     /**
diff --git 
a/openjpa-kernel/src/test/java/org/apache/openjpa/conf/SpecificationAdditionalTests.java
 
b/openjpa-kernel/src/test/java/org/apache/openjpa/conf/SpecificationAdditionalTests.java
new file mode 100644
index 0000000..e908fbf
--- /dev/null
+++ 
b/openjpa-kernel/src/test/java/org/apache/openjpa/conf/SpecificationAdditionalTests.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.conf;
+
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import static org.junit.Assert.*;
+import org.apache.openjpa.lib.meta.ClassMetaDataIterator;
+import org.apache.openjpa.meta.ClassMetaData;
+import org.junit.Assert;
+import org.apache.openjpa.conf.*;
+
+public class SpecificationAdditionalTests {
+
+       String myString = "JPA";
+       String myCompleteString = "JPA 2.0-draft";
+       String myCompleteString2 = "JPA 2.1-draft";
+       String myHalfCompleteString = "JPA 2";
+       String myHalfCompleteString2 = "JPQ 2";
+       String myNullString = null;
+
+       
+       @Test
+       public void EqualsTest() { 
+               Specification spec = new Specification(myString);
+               Assert.assertTrue(spec.equals(spec)); // parse() is overidded 
in Specification
+       }
+
+       @Test
+       public void EqualsTest2() {
+               Specification spec = new Specification(myString);
+               Assert.assertFalse(spec.equals(myNullString)); // parse() is 
overidded in Specification
+       }
+               
+       
+       @Test 
+       public void EqualsTest3() { 
+               Specification spec = new Specification(myString);
+               Specification spec2 = new Specification(myHalfCompleteString);
+               Assert.assertFalse(spec.equals(spec2)); // parse() is overidded 
in Specification
+       }
+
+        @Test      
+       public void EqualsTest4() { 
+               Specification spec = new Specification(myString);
+               Assert.assertFalse(spec.equals(1)); // parse() is overidded in 
Specification
+       }
+       
+       @Test 
+       public void EqualsTest5() {  
+               Specification spec = new Specification(myHalfCompleteString);
+               Specification spec2 = new Specification(myHalfCompleteString2);
+               Assert.assertFalse(spec.equals(spec2)); 
+       }
+       
+       @Test 
+       public void EqualsTest6() { 
+               Specification spec = new Specification(myCompleteString);
+               Specification spec2 = new Specification(myHalfCompleteString2);
+               Assert.assertFalse(spec.equals(spec2)); 
+       }
+       
+       
+}

Reply via email to