wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r814097 - in /incubator/wink/trunk/wink-providers: wink-jackson-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jackson/ wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/
Date Sat, 12 Sep 2009 00:59:31 GMT
Author: bluk
Date: Sat Sep 12 00:59:31 2009
New Revision: 814097

URL: http://svn.apache.org/viewvc?rev=814097&view=rev
Log:
Fix JSON comparisions to use JSONUtils

Modified:
    incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jackson/JacksonJAXBTest.java
    incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/JettisonJAXBBadgerFishTest.java
    incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/JettisonJAXBMappedTest.java

Modified: incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jackson/JacksonJAXBTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jackson/JacksonJAXBTest.java?rev=814097&r1=814096&r2=814097&view=diff
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jackson/JacksonJAXBTest.java
(original)
+++ incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jackson/JacksonJAXBTest.java
Sat Sep 12 00:59:31 2009
@@ -151,8 +151,8 @@
         MockHttpServletResponse response = invoke(request);
         assertEquals(200, response.getStatus());
 
-        assertEquals(new JSONObject("{\"desc\":\"My desc\",\"name\":\"My Name\"}").toString(),
-                     new JSONObject(response.getContentAsString()).toString());
+        assertTrue(JSONUtils.equals(new JSONObject("{\"desc\":\"My desc\",\"name\":\"My Name\"}"),
+                                    new JSONObject(response.getContentAsString())));
     }
 
     /**
@@ -167,8 +167,8 @@
         request.setContent("{\"desc\":\"My desc\",\"name\":\"My Name\"}".getBytes());
         MockHttpServletResponse response = invoke(request);
         assertEquals(200, response.getStatus());
-        assertEquals(new JSONObject("{\"desc\":\"My desc\",\"name\":\"My Name\"}").toString(),
-                     new JSONObject(response.getContentAsString()).toString());
+        assertTrue(JSONUtils.equals(new JSONObject("{\"desc\":\"My desc\",\"name\":\"My Name\"}"),
+                                    new JSONObject(response.getContentAsString())));
     }
 
     public void testGetAtomEntry() throws Exception {
@@ -178,7 +178,6 @@
                                                         "application/json");
         MockHttpServletResponse response = invoke(request);
         assertEquals(200, response.getStatus());
-        assertEquals(ENTRY_JSON, response.getContentAsString());
         assertTrue(JSONUtils.equals(JSONUtils.objectForString(ENTRY_JSON), JSONUtils
             .objectForString(response.getContentAsString())));
     }
@@ -196,7 +195,7 @@
     }
 
     /*
-     * NOTE:  this test is currently disabled, as the Jackson-supplied provider
+     * NOTE: this test is currently disabled, as the Jackson-supplied provider
      * cannot tolerate org.w3c.dom.Element fields in the various Atom* objects
      */
     public void _testPostAtomEntry() throws Exception {
@@ -213,45 +212,39 @@
             .objectForString(response.getContentAsString())));
     }
 
-
-    private static final String ENTRY_STR = 
-        "<entry xml:base=\"http://b216:8080/reporting/reports\" xmlns=\"http://www.w3.org/2005/Atom\">\n"
-            + "    <id>toptenvalidators</id>\n"
-            + "    <updated>2009-08-31T18:30:02Z</updated>\n"
-            + "    <title type=\"text\" xml:lang=\"en\">top ten validators</title>\n"
-            + "    <published>2009-08-31T18:30:02Z</published>\n"
-            + "    <link href=\"http://b216:8080/reporting/reports/toptenvalidators?alt=application/json\"
type=\"application/json\" rel=\"alternate\"/>\n"
-            + "    <author>\n"
-            + "        <name>admin</name>\n"
-            + "    </author>\n"
-            + "    <category label=\"report definition\" scheme=\"urn:com:systinet:reporting:kind\"
term=\"urn:com:systinet:reporting:kind:definition\"/>\n"
-            + "</entry>\n";
-
-    private static final String ENTRY_STR_JSON_POST = 
-        "{"
-        + "\"id\":\"top ten validators\",\"updated\":@TIME_JSON@,\"title\":{\"lang\":\"en\",\"otherAttributes\":{},\"any\":[\"top
ten validators\"],\"type\":\"text\"}"
-        + "}";
-
-    private static final String ENTRY_STR_JSON =                                        
          
-        "{\"base\":\"http://b216:8080/reporting/reports\","
-        + "\"otherAttributes\":{},"
-        + "\"id\":\"toptenvalidators\","
-        + "\"updated\":{\"year\":2009,\"month\":8,\"day\":31,\"timezone\":0,\"hour\":18,\"minute\":30,\"second\":2,\"millisecond\":-2147483648},"
-        + "\"title\":{\"lang\":\"en\",\"otherAttributes\":{},\"type\":\"text\"},"
-        + "\"published\":{\"year\":2009,\"month\":8,\"day\":31,\"timezone\":0,\"hour\":18,\"minute\":30,\"second\":2,\"millisecond\":-2147483648},"
-        + "\"link\":[{\"otherAttributes\":{},\"rel\":\"alternate\",\"type\":\"application/json\",\"href\":\"http://b216:8080/reporting/reports/toptenvalidators?alt=application/json\"}],"
-        + "\"author\":[{\"name\":\"admin\"}],"
-        + "\"category\":[{\"otherAttributes\":{},\"term\":\"urn:com:systinet:reporting:kind:definition\",\"scheme\":\"urn:com:systinet:reporting:kind\",\"label\":\"report
definition\"}]"
-        + "}";
-
-    private static final String ENTRY_STR_JSON_GET = 
-        "{\"name\":{\"namespaceURI\":\"http://www.w3.org/2005/Atom\",\"localPart\":\"entry\",\"prefix\":\"\"},"
-        + "\"declaredType\":\"org.apache.wink.common.model.atom.AtomEntry\","
-        + "\"scope\":\"javax.xml.bind.JAXBElement$GlobalScope\","
-        + "\"value\":"
-        + ENTRY_STR_JSON
-        + ",\"nil\":false}";
-    
+    private static final String ENTRY_STR           =
+                                                        "<entry xml:base=\"http://b216:8080/reporting/reports\"
xmlns=\"http://www.w3.org/2005/Atom\">\n" + "    <id>toptenvalidators</id>\n"
+                                                            + "    <updated>2009-08-31T18:30:02Z</updated>\n"
+                                                            + "    <title type=\"text\"
xml:lang=\"en\">top ten validators</title>\n"
+                                                            + "    <published>2009-08-31T18:30:02Z</published>\n"
+                                                            + "    <link href=\"http://b216:8080/reporting/reports/toptenvalidators?alt=application/json\"
type=\"application/json\" rel=\"alternate\"/>\n"
+                                                            + "    <author>\n"
+                                                            + "        <name>admin</name>\n"
+                                                            + "    </author>\n"
+                                                            + "    <category label=\"report
definition\" scheme=\"urn:com:systinet:reporting:kind\" term=\"urn:com:systinet:reporting:kind:definition\"/>\n"
+                                                            + "</entry>\n";
+
+    private static final String ENTRY_STR_JSON_POST =
+                                                        "{" + "\"id\":\"top ten validators\",\"updated\":@TIME_JSON@,\"title\":{\"lang\":\"en\",\"otherAttributes\":{},\"any\":[\"top
ten validators\"],\"type\":\"text\"}"
+                                                            + "}";
+
+    private static final String ENTRY_STR_JSON      =
+                                                        "{\"base\":\"http://b216:8080/reporting/reports\","
+ "\"otherAttributes\":{},"
+                                                            + "\"id\":\"toptenvalidators\","
+                                                            + "\"updated\":{\"year\":2009,\"month\":8,\"day\":31,\"timezone\":0,\"hour\":18,\"minute\":30,\"second\":2,\"millisecond\":-2147483648},"
+                                                            + "\"title\":{\"lang\":\"en\",\"otherAttributes\":{},\"type\":\"text\"},"
+                                                            + "\"published\":{\"year\":2009,\"month\":8,\"day\":31,\"timezone\":0,\"hour\":18,\"minute\":30,\"second\":2,\"millisecond\":-2147483648},"
+                                                            + "\"link\":[{\"otherAttributes\":{},\"rel\":\"alternate\",\"type\":\"application/json\",\"href\":\"http://b216:8080/reporting/reports/toptenvalidators?alt=application/json\"}],"
+                                                            + "\"author\":[{\"name\":\"admin\"}],"
+                                                            + "\"category\":[{\"otherAttributes\":{},\"term\":\"urn:com:systinet:reporting:kind:definition\",\"scheme\":\"urn:com:systinet:reporting:kind\",\"label\":\"report
definition\"}]"
+                                                            + "}";
+
+    private static final String ENTRY_STR_JSON_GET  =
+                                                        "{\"name\":{\"namespaceURI\":\"http://www.w3.org/2005/Atom\",\"localPart\":\"entry\",\"prefix\":\"\"},"
+ "\"declaredType\":\"org.apache.wink.common.model.atom.AtomEntry\","
+                                                            + "\"scope\":\"javax.xml.bind.JAXBElement$GlobalScope\","
+                                                            + "\"value\":"
+                                                            + ENTRY_STR_JSON
+                                                            + ",\"nil\":false}";
 
     private static final String ENTRY_JSON;
 
@@ -280,7 +273,7 @@
 
         ENTRY_JSON = ENTRY_STR_JSON.replaceAll("@TIME_JSON@", jsonTimeStr);
         ENTRY_JSON_POST = ENTRY_STR_JSON_POST.replaceAll("@TIME_JSON@", jsonTimeStr);
-        
+
     }
 
 }

Modified: incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/JettisonJAXBBadgerFishTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/JettisonJAXBBadgerFishTest.java?rev=814097&r1=814096&r2=814097&view=diff
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/JettisonJAXBBadgerFishTest.java
(original)
+++ incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/JettisonJAXBBadgerFishTest.java
Sat Sep 12 00:59:31 2009
@@ -40,7 +40,7 @@
 import org.apache.wink.server.internal.providers.entity.jettison.jaxb.Person;
 import org.apache.wink.server.internal.servlet.MockServletInvocationTest;
 import org.apache.wink.test.mock.MockRequestConstructor;
-import org.codehaus.jettison.json.JSONObject;
+import org.json.JSONObject;
 import org.springframework.mock.web.MockHttpServletRequest;
 import org.springframework.mock.web.MockHttpServletResponse;
 
@@ -51,7 +51,8 @@
 
     @Override
     protected Class<?>[] getClasses() {
-        return new Class<?>[] {TestResource.class, PersonResource.class, FormattingOptionsContextResolver.class};
+        return new Class<?>[] {TestResource.class, PersonResource.class,
+            FormattingOptionsContextResolver.class};
     }
 
     @Override
@@ -146,10 +147,10 @@
         MockHttpServletResponse response = invoke(request);
         assertEquals(200, response.getStatus());
 
-        assertEquals(new JSONObject(
-                                    " {\"person\":{\"desc\":{\"$\":\"My desc\"},\"name\":{\"$\":\"My
Name\"}}} ")
-                         .toString(),
-                     new JSONObject(response.getContentAsString()).toString());
+        assertTrue(JSONUtils
+            .equals(new JSONObject(
+                                   " {\"person\":{\"desc\":{\"$\":\"My desc\"},\"name\":{\"$\":\"My
Name\"}}} "),
+                    new JSONObject(response.getContentAsString())));
     }
 
     /**
@@ -166,10 +167,9 @@
                 .getBytes());
         MockHttpServletResponse response = invoke(request);
         assertEquals(200, response.getStatus());
-        assertEquals(new JSONObject(
-                                    " {\"person\":{\"desc\":{\"$\":\"My desc\"},\"name\":{\"$\":\"My
Name\"}}} ")
-                         .toString(),
-                     new JSONObject(response.getContentAsString()).toString());
+        assertTrue(JSONUtils.equals(new JSONObject(
+                                    " {\"person\":{\"desc\":{\"$\":\"My desc\"},\"name\":{\"$\":\"My
Name\"}}} "),
+                     new JSONObject(response.getContentAsString())));
     }
 
     public void testGetAtomEntry() throws Exception {
@@ -179,7 +179,6 @@
                                                         "application/json");
         MockHttpServletResponse response = invoke(request);
         assertEquals(200, response.getStatus());
-        System.out.println(response.getContentAsString());
         assertTrue(JSONUtils.equals(JSONUtils.objectForString(ENTRY_JSON), JSONUtils
             .objectForString(response.getContentAsString())));
     }

Modified: incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/JettisonJAXBMappedTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/JettisonJAXBMappedTest.java?rev=814097&r1=814096&r2=814097&view=diff
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/JettisonJAXBMappedTest.java
(original)
+++ incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/server/internal/providers/entity/jettison/JettisonJAXBMappedTest.java
Sat Sep 12 00:59:31 2009
@@ -43,8 +43,8 @@
 import org.apache.wink.server.internal.providers.entity.jettison.jaxb.Person;
 import org.apache.wink.server.internal.servlet.MockServletInvocationTest;
 import org.apache.wink.test.mock.MockRequestConstructor;
-import org.codehaus.jettison.json.JSONObject;
 import org.codehaus.jettison.mapped.Configuration;
+import org.json.JSONObject;
 import org.springframework.mock.web.MockHttpServletRequest;
 import org.springframework.mock.web.MockHttpServletResponse;
 
@@ -167,10 +167,10 @@
         MockHttpServletResponse response = invoke(request);
         assertEquals(200, response.getStatus());
 
-        assertEquals(new JSONObject(
-                                    " { \"person\" : { \"desc\" : \"My desc\", \"name\" :
\"My Name\" } } ")
-                         .toString(),
-                     new JSONObject(response.getContentAsString()).toString());
+        assertTrue(JSONUtils
+            .equals(new JSONObject(
+                                   " { \"person\" : { \"desc\" : \"My desc\", \"name\" :
\"My Name\" } } "),
+                    new JSONObject(response.getContentAsString())));
     }
 
     /**
@@ -186,8 +186,9 @@
             .getBytes());
         MockHttpServletResponse response = invoke(request);
         assertEquals(200, response.getStatus());
-        assertEquals("{\"person\":{\"desc\":\"My desc\",\"name\":\"My Name\"}}", response
-            .getContentAsString());
+        assertTrue(JSONUtils
+            .equals(new JSONObject("{\"person\":{\"desc\":\"My desc\",\"name\":\"My Name\"}}"),
+                    new JSONObject(response.getContentAsString())));
     }
 
     public void testGetAtomEntry() throws Exception {
@@ -198,8 +199,8 @@
         MockHttpServletResponse response = invoke(request);
         assertEquals(200, response.getStatus());
 
-        assertEquals(new JSONObject(ENTRY_JSON).toString(), new JSONObject(response
-            .getContentAsString()).toString());
+        assertTrue(JSONUtils.equals(new JSONObject(ENTRY_JSON), new JSONObject(response
+            .getContentAsString())));
     }
 
     public void testGetAtomEntryElement() throws Exception {
@@ -209,8 +210,8 @@
                                                         "application/json");
         MockHttpServletResponse response = invoke(request);
         assertEquals(200, response.getStatus());
-        assertEquals(new JSONObject(ENTRY_JSON).toString(), new JSONObject(response
-            .getContentAsString()).toString());
+        assertTrue(JSONUtils.equals(new JSONObject(ENTRY_JSON), new JSONObject(response
+            .getContentAsString())));
     }
 
     public void testPostAtomEntry() throws Exception {



Mime
View raw message