Author: lryan
Date: Tue Mar  3 22:45:55 2009
New Revision: 749811

URL: http://svn.apache.org/viewvc?rev=749811&view=rev
Log:
Fix for comparison failures when rvalue is null or both values are undefined

Modified:
    
incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/common/JsonAssert.java

Modified: 
incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/common/JsonAssert.java
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/common/JsonAssert.java?rev=749811&r1=749810&r2=749811&view=diff
==============================================================================
--- 
incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/common/JsonAssert.java
 (original)
+++ 
incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/common/JsonAssert.java
 Tue Mar  3 22:45:55 2009
@@ -18,10 +18,10 @@
  */
 package org.apache.shindig.common;
 
-import static org.junit.Assert.assertEquals;
-
 import org.json.JSONArray;
 import org.json.JSONObject;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
 public final class JsonAssert {
   private JsonAssert() {}
@@ -53,10 +53,17 @@
       assertEquals("Objects are not of equal size", left.toString(2), 
right.toString(2));
     }
 
+    // Both are emtpy so skip
+    if (JSONObject.getNames(left) == null && JSONObject.getNames(right) == 
null) {
+      return;
+    }
     for (String name : JSONObject.getNames(left)) {
       Object leftValue = left.opt(name);
       Object rightValue = right.opt(name);
 
+      if (leftValue != null) {
+        assertNotNull(left.toString() + " != " + right.toString(), rightValue);
+      }
       assertEquals(left.toString() + " != " + right.toString(),
                    leftValue.getClass(), rightValue.getClass());
 


Reply via email to