You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2016/03/16 09:04:20 UTC

[2/3] camel git commit: CAMEL-9708: Fixed equals to support both array and pojo based. Fixed tests in jackson

CAMEL-9708: Fixed equals to support both array and pojo based. Fixed tests in jackson


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/fc0eb8c5
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/fc0eb8c5
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/fc0eb8c5

Branch: refs/heads/master
Commit: fc0eb8c57b6fc145b69202c87bdd5091878670f1
Parents: 7786a32
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Mar 16 09:01:27 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Mar 16 09:01:27 2016 +0100

----------------------------------------------------------------------
 .../org/apache/camel/util/ObjectHelper.java     |  8 +++++-
 .../camel/component/jackson/TestJAXBPojo.java   |  2 +-
 .../camel/component/jackson/TestPojoView.java   | 28 +++++++++++++++++++
 .../component/jacksonxml/TestJAXBPojo.java      |  2 +-
 .../component/jacksonxml/TestPojoView.java      | 29 ++++++++++++++++++++
 5 files changed, 66 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/fc0eb8c5/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java b/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
index b62e86c..65372f0 100644
--- a/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
@@ -209,7 +209,13 @@ public final class ObjectHelper {
             }
         }
 
-        return Objects.deepEquals(a, b);
+        if (a.getClass().isArray() && b.getClass().isArray()) {
+            // uses array based equals
+            return Objects.deepEquals(a, b);
+        } else {
+            // use regular equals
+            return a.equals(b);
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/camel/blob/fc0eb8c5/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/TestJAXBPojo.java
----------------------------------------------------------------------
diff --git a/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/TestJAXBPojo.java b/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/TestJAXBPojo.java
index 20cee37..b5b0cd6 100644
--- a/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/TestJAXBPojo.java
+++ b/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/TestJAXBPojo.java
@@ -35,7 +35,7 @@ public class TestJAXBPojo {
 
     @Override
     public boolean equals(Object obj) {
-        return this.name.equals(((TestPojo) obj).getName());
+        return this.name.equals(((TestJAXBPojo) obj).getName());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/fc0eb8c5/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/TestPojoView.java
----------------------------------------------------------------------
diff --git a/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/TestPojoView.java b/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/TestPojoView.java
index 7062a37..1a57b34 100644
--- a/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/TestPojoView.java
+++ b/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/TestPojoView.java
@@ -53,4 +53,32 @@ public class TestPojoView {
     public void setWeight(int weight) {
         this.weight = weight;
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+
+        TestPojoView that = (TestPojoView) o;
+
+        if (age != that.age) {
+            return false;
+        }
+        if (height != that.height) {
+            return false;
+        }
+        return weight == that.weight;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = age;
+        result = 31 * result + height;
+        result = 31 * result + weight;
+        return result;
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/fc0eb8c5/components/camel-jacksonxml/src/test/java/org/apache/camel/component/jacksonxml/TestJAXBPojo.java
----------------------------------------------------------------------
diff --git a/components/camel-jacksonxml/src/test/java/org/apache/camel/component/jacksonxml/TestJAXBPojo.java b/components/camel-jacksonxml/src/test/java/org/apache/camel/component/jacksonxml/TestJAXBPojo.java
index 2291d55..2c302d1 100644
--- a/components/camel-jacksonxml/src/test/java/org/apache/camel/component/jacksonxml/TestJAXBPojo.java
+++ b/components/camel-jacksonxml/src/test/java/org/apache/camel/component/jacksonxml/TestJAXBPojo.java
@@ -35,7 +35,7 @@ public class TestJAXBPojo {
 
     @Override
     public boolean equals(Object obj) {
-        return this.name.equals(((TestPojo) obj).getName());
+        return this.name.equals(((TestJAXBPojo) obj).getName());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/fc0eb8c5/components/camel-jacksonxml/src/test/java/org/apache/camel/component/jacksonxml/TestPojoView.java
----------------------------------------------------------------------
diff --git a/components/camel-jacksonxml/src/test/java/org/apache/camel/component/jacksonxml/TestPojoView.java b/components/camel-jacksonxml/src/test/java/org/apache/camel/component/jacksonxml/TestPojoView.java
index 8535dae..890a1c5 100644
--- a/components/camel-jacksonxml/src/test/java/org/apache/camel/component/jacksonxml/TestPojoView.java
+++ b/components/camel-jacksonxml/src/test/java/org/apache/camel/component/jacksonxml/TestPojoView.java
@@ -53,4 +53,33 @@ public class TestPojoView {
     public void setWeight(int weight) {
         this.weight = weight;
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+
+        TestPojoView that = (TestPojoView) o;
+
+        if (age != that.age) {
+            return false;
+        }
+        if (height != that.height) {
+            return false;
+        }
+        return weight == that.weight;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = age;
+        result = 31 * result + height;
+        result = 31 * result + weight;
+        return result;
+    }
+
 }