incubator-wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r1292070 - in /incubator/wink/trunk/wink-providers/wink-jackson-provider: ./ src/main/java/org/apache/wink/providers/jackson/ src/test/java/org/apache/wink/providers/jackson/internal/
Date Tue, 21 Feb 2012 22:48:30 GMT
Author: rfeng
Date: Tue Feb 21 22:48:30 2012
New Revision: 1292070

URL: http://svn.apache.org/viewvc?rev=1292070&view=rev
Log:
Upgrade to the latest jackson version

Modified:
    incubator/wink/trunk/wink-providers/wink-jackson-provider/pom.xml
    incubator/wink/trunk/wink-providers/wink-jackson-provider/src/main/java/org/apache/wink/providers/jackson/WinkJacksonJaxbJsonProvider.java
    incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/JacksonDeserializationConfiguration2Test.java

Modified: incubator/wink/trunk/wink-providers/wink-jackson-provider/pom.xml
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jackson-provider/pom.xml?rev=1292070&r1=1292069&r2=1292070&view=diff
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jackson-provider/pom.xml (original)
+++ incubator/wink/trunk/wink-providers/wink-jackson-provider/pom.xml Tue Feb 21 22:48:30
2012
@@ -31,22 +31,22 @@
         <dependency>
             <groupId>org.codehaus.jackson</groupId>
             <artifactId>jackson-core-asl</artifactId>
-            <version>1.8.0</version>
+            <version>1.9.4</version>
         </dependency>
         <dependency>
             <groupId>org.codehaus.jackson</groupId>
             <artifactId>jackson-mapper-asl</artifactId>
-            <version>1.8.0</version>
+            <version>1.9.4</version>
         </dependency>
         <dependency>
             <groupId>org.codehaus.jackson</groupId>
             <artifactId>jackson-jaxrs</artifactId>
-            <version>1.8.0</version>
+            <version>1.9.4</version>
         </dependency>
         <dependency>
             <groupId>org.codehaus.jackson</groupId>
             <artifactId>jackson-xc</artifactId>
-            <version>1.8.0</version>
+            <version>1.9.4</version>
         </dependency>
         <dependency>
             <groupId>org.apache.wink</groupId>

Modified: incubator/wink/trunk/wink-providers/wink-jackson-provider/src/main/java/org/apache/wink/providers/jackson/WinkJacksonJaxbJsonProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jackson-provider/src/main/java/org/apache/wink/providers/jackson/WinkJacksonJaxbJsonProvider.java?rev=1292070&r1=1292069&r2=1292070&view=diff
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jackson-provider/src/main/java/org/apache/wink/providers/jackson/WinkJacksonJaxbJsonProvider.java
(original)
+++ incubator/wink/trunk/wink-providers/wink-jackson-provider/src/main/java/org/apache/wink/providers/jackson/WinkJacksonJaxbJsonProvider.java
Tue Feb 21 22:48:30 2012
@@ -19,22 +19,16 @@
  *******************************************************************************/
 package org.apache.wink.providers.jackson;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-
 import javax.ws.rs.Consumes;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.ext.MessageBodyReader;
 import javax.ws.rs.ext.MessageBodyWriter;
 import javax.ws.rs.ext.Provider;
 
 import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider;
 import org.codehaus.jackson.map.AnnotationIntrospector;
+import org.codehaus.jackson.map.DeserializationConfig.Feature;
 import org.codehaus.jackson.map.ObjectMapper;
 import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
 import org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector;
@@ -43,72 +37,24 @@ import org.codehaus.jackson.xc.JaxbAnnot
 @Provider
 @Consumes( {MediaType.APPLICATION_JSON, "text/json"})
 @Produces( {MediaType.APPLICATION_JSON, "text/json"})
-public class WinkJacksonJaxbJsonProvider implements MessageBodyReader<Object>, MessageBodyWriter<Object>
{
-
-    JacksonJaxbJsonProvider jacksonProvider;
+public class WinkJacksonJaxbJsonProvider extends JacksonJaxbJsonProvider implements MessageBodyReader<Object>,
MessageBodyWriter<Object> {
 
     public WinkJacksonJaxbJsonProvider() {
+        super(createObjectMapper(), BASIC_ANNOTATIONS);
+    }
+
+    private static ObjectMapper createObjectMapper() {
         ObjectMapper mapper = new ObjectMapper();
         mapper.getSerializationConfig().setSerializationInclusion(Inclusion.NON_NULL);
+        mapper.getDeserializationConfig().set(Feature.FAIL_ON_UNKNOWN_PROPERTIES, Boolean.FALSE);
+//        mapper.getSerializationConfig().setDateFormat(StdDateFormat.getBlueprintISO8601Format());
+//        mapper.getDeserializationConfig().setDateFormat(StdDateFormat.getBlueprintISO8601Format());
         AnnotationIntrospector pair =
             new AnnotationIntrospector.Pair(new JaxbAnnotationIntrospector(),
                                             new JacksonAnnotationIntrospector());
         mapper.getDeserializationConfig().setAnnotationIntrospector(pair);
         mapper.getSerializationConfig().setAnnotationIntrospector(pair);
-        this.jacksonProvider = new JacksonJaxbJsonProvider();
-        jacksonProvider.setMapper(mapper);
-    }
-
-    public long getSize(Object t,
-                        Class<?> type,
-                        Type genericType,
-                        Annotation[] annotations,
-                        MediaType mediaType) {
-        return jacksonProvider.getSize(t, type, genericType, annotations, mediaType);
-    }
-
-    public boolean isWriteable(Class<?> type,
-                               Type genericType,
-                               Annotation[] annotations,
-                               MediaType mediaType) {
-        return jacksonProvider.isWriteable(type, genericType, annotations, mediaType);
-    }
-
-    public void writeTo(Object t,
-                        Class<?> type,
-                        Type genericType,
-                        Annotation[] annotations,
-                        MediaType mediaType,
-                        MultivaluedMap<String, Object> httpHeaders,
-                        OutputStream entityStream) throws IOException {
-        jacksonProvider.writeTo(t,
-                                type,
-                                genericType,
-                                annotations,
-                                mediaType,
-                                httpHeaders,
-                                entityStream);
-    }
-
-    public boolean isReadable(Class<?> type,
-                              Type genericType,
-                              Annotation[] annotations,
-                              MediaType mediaType) {
-        return jacksonProvider.isReadable(type, genericType, annotations, mediaType);
-    }
-
-    public Object readFrom(Class<Object> type,
-                           Type genericType,
-                           Annotation[] annotations,
-                           MediaType mediaType,
-                           MultivaluedMap<String, String> httpHeaders,
-                           InputStream entityStream) throws IOException {
-        return jacksonProvider.readFrom(type,
-                                        genericType,
-                                        annotations,
-                                        mediaType,
-                                        httpHeaders,
-                                        entityStream);
+        return mapper;
     }
 
 }

Modified: incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/JacksonDeserializationConfiguration2Test.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/JacksonDeserializationConfiguration2Test.java?rev=1292070&r1=1292069&r2=1292070&view=diff
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/JacksonDeserializationConfiguration2Test.java
(original)
+++ incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/JacksonDeserializationConfiguration2Test.java
Tue Feb 21 22:48:30 2012
@@ -25,7 +25,6 @@ import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
 
-import javax.servlet.ServletException;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
@@ -113,10 +112,9 @@ public class JacksonDeserializationConfi
                                                         MediaType.APPLICATION_JSON);
         request.setContentType(MediaType.APPLICATION_JSON);
         request.setContent("{\"children\":[\"Joe\",\"Sally\",\"Steve\"]}".getBytes());
-        try{
-            invoke(request);
-            fail("ServletException not thrown for missing setter method of children.");
-        } catch(ServletException e) {}
+        // No jackson 1.9.x support the List without setter
+        MockHttpServletResponse response = invoke(request);
+        assertEquals(200, response.getStatus());
     }
     
     public void testPOSTPersonWithAgeWeight() throws Exception {



Mime
View raw message