wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r822995 - in /incubator/wink/trunk: wink-itests/wink-itest/wink-itest-client/src/test/java/org/apache/wink/itest/client/ wink-providers/wink-json-provider/src/main/java/org/apache/wink/providers/json/
Date Thu, 08 Oct 2009 01:30:55 GMT
Author: bluk
Date: Thu Oct  8 01:30:55 2009
New Revision: 822995

URL: http://svn.apache.org/viewvc?rev=822995&view=rev
Log:
Update JSON provider to avoid client exception

Modified:
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-client/src/test/java/org/apache/wink/itest/client/AcceptHeaderHandlerApacheHTTPCoreTest.java
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-client/src/test/java/org/apache/wink/itest/client/AcceptHeaderHandlerTest.java
    incubator/wink/trunk/wink-itests/wink-itest/wink-itest-client/src/test/java/org/apache/wink/itest/client/NoAcceptHeaderHandlerTest.java
    incubator/wink/trunk/wink-providers/wink-json-provider/src/main/java/org/apache/wink/providers/json/JsonProvider.java

Modified: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-client/src/test/java/org/apache/wink/itest/client/AcceptHeaderHandlerApacheHTTPCoreTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-client/src/test/java/org/apache/wink/itest/client/AcceptHeaderHandlerApacheHTTPCoreTest.java?rev=822995&r1=822994&r2=822995&view=diff
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-client/src/test/java/org/apache/wink/itest/client/AcceptHeaderHandlerApacheHTTPCoreTest.java
(original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-client/src/test/java/org/apache/wink/itest/client/AcceptHeaderHandlerApacheHTTPCoreTest.java
Thu Oct  8 01:30:55 2009
@@ -37,7 +37,7 @@
     public void setUp() throws Exception {
         super.setUp();
         ClientConfig config = new ApacheHttpClientConfig();
-        config.setLoadWinkApplications(false);
+//        config.setLoadWinkApplications(false);
         config.applications(new Application() {
 
             @Override

Modified: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-client/src/test/java/org/apache/wink/itest/client/AcceptHeaderHandlerTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-client/src/test/java/org/apache/wink/itest/client/AcceptHeaderHandlerTest.java?rev=822995&r1=822994&r2=822995&view=diff
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-client/src/test/java/org/apache/wink/itest/client/AcceptHeaderHandlerTest.java
(original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-client/src/test/java/org/apache/wink/itest/client/AcceptHeaderHandlerTest.java
Thu Oct  8 01:30:55 2009
@@ -58,7 +58,7 @@
         super.setUp();
 
         ClientConfig config = new ApacheHttpClientConfig();
-        config.setLoadWinkApplications(false);
+//        config.setLoadWinkApplications(false);
         config.applications(new Application() {
 
             @Override

Modified: incubator/wink/trunk/wink-itests/wink-itest/wink-itest-client/src/test/java/org/apache/wink/itest/client/NoAcceptHeaderHandlerTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-itests/wink-itest/wink-itest-client/src/test/java/org/apache/wink/itest/client/NoAcceptHeaderHandlerTest.java?rev=822995&r1=822994&r2=822995&view=diff
==============================================================================
--- incubator/wink/trunk/wink-itests/wink-itest/wink-itest-client/src/test/java/org/apache/wink/itest/client/NoAcceptHeaderHandlerTest.java
(original)
+++ incubator/wink/trunk/wink-itests/wink-itest/wink-itest-client/src/test/java/org/apache/wink/itest/client/NoAcceptHeaderHandlerTest.java
Thu Oct  8 01:30:55 2009
@@ -135,8 +135,13 @@
      */
     public void testAcceptHeaderForJAXB() {
         try {
-            client.resource(getBaseURI() + "/echoaccept").get(Echo.class);
+            Echo e  = client.resource(getBaseURI() + "/echoaccept").get(Echo.class);
             fail();
+//            String value = e.getValue();
+//            assertTrue(value, value.contains(MediaType.APPLICATION_JSON));
+//            assertTrue(value, value.contains(MediaType.APPLICATION_XML));
+//            assertTrue(value, value.contains(MediaType.TEXT_XML));
+//            assertTrue(value, value.contains("application/javascript"));
         } catch (RuntimeException e) {
             assertEquals(e.getMessage(), String
                 .format("No reader for type class %s and media type %s",
@@ -151,8 +156,11 @@
      */
     public void testAcceptHeaderForJSON() throws JSONException {
         try {
-            client.resource(getBaseURI() + "/echoaccept").get(JSONObject.class);
+            JSONObject j = client.resource(getBaseURI() + "/echoaccept").get(JSONObject.class);
             fail();
+            // String value = j.getString("value");
+            // assertTrue(value, value.contains(MediaType.APPLICATION_JSON));
+            // assertTrue(value, value.contains("application/javascript"));
         } catch (RuntimeException e) {
             assertEquals(e.getMessage(), String
                 .format("No reader for type class %s and media type %s",

Modified: incubator/wink/trunk/wink-providers/wink-json-provider/src/main/java/org/apache/wink/providers/json/JsonProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-json-provider/src/main/java/org/apache/wink/providers/json/JsonProvider.java?rev=822995&r1=822994&r2=822995&view=diff
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-json-provider/src/main/java/org/apache/wink/providers/json/JsonProvider.java
(original)
+++ incubator/wink/trunk/wink-providers/wink-json-provider/src/main/java/org/apache/wink/providers/json/JsonProvider.java
Thu Oct  8 01:30:55 2009
@@ -52,8 +52,7 @@
 @Provider
 @Consumes( {MediaType.APPLICATION_JSON, MediaTypeUtils.JAVASCRIPT})
 @Produces( {MediaType.APPLICATION_JSON, MediaTypeUtils.JAVASCRIPT})
-public class JsonProvider implements MessageBodyWriter<JSONObject>,
-    MessageBodyReader<JSONObject> {
+public class JsonProvider implements MessageBodyWriter<JSONObject>, MessageBodyReader<JSONObject>
{
 
     private static final Logger logger = LoggerFactory.getLogger(JsonProvider.class);
 
@@ -90,8 +89,13 @@
             throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR);
         }
 
-        String callbackParam =
-            uriInfo.getQueryParameters().getFirst(RestConstants.REST_PARAM_JSON_CALLBACK);
+        String callbackParam = null;
+        try {
+            callbackParam =
+                uriInfo.getQueryParameters().getFirst(RestConstants.REST_PARAM_JSON_CALLBACK);
+        } catch (Exception e) {
+            logger.debug("Could not get the URI callback param", e);
+        }
         OutputStreamWriter writer =
             new OutputStreamWriter(entityStream, ProviderUtils.getCharset(mediaType));
         if (callbackParam != null) {



Mime
View raw message