wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r997531 - in /incubator/wink/trunk/wink-providers/wink-jackson-provider: ./ src/test/java/org/apache/wink/providers/jackson/internal/
Date Wed, 15 Sep 2010 22:46:18 GMT
Author: bluk
Date: Wed Sep 15 22:46:18 2010
New Revision: 997531

URL: http://svn.apache.org/viewvc?rev=997531&view=rev
Log:
Update to use Jackson 1.6.0

Thanks to Jason Dillon for the suggestion.

Updates to testcases to deal with changes
in Jackson's default behavior.

Modified:
    incubator/wink/trunk/wink-providers/wink-jackson-provider/pom.xml
    incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/JAXBCollectionJSONTest.java
    incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/JacksonJAXBTest.java
    incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/PolymorphicTest.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=997531&r1=997530&r2=997531&view=diff
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jackson-provider/pom.xml (original)
+++ incubator/wink/trunk/wink-providers/wink-jackson-provider/pom.xml Wed Sep 15 22:46:18
2010
@@ -31,22 +31,22 @@
         <dependency>
             <groupId>org.codehaus.jackson</groupId>
             <artifactId>jackson-core-asl</artifactId>
-            <version>1.4.0</version>
+            <version>1.6.0</version>
         </dependency>
         <dependency>
             <groupId>org.codehaus.jackson</groupId>
             <artifactId>jackson-mapper-asl</artifactId>
-            <version>1.4.0</version>
+            <version>1.6.0</version>
         </dependency>
         <dependency>
             <groupId>org.codehaus.jackson</groupId>
             <artifactId>jackson-jaxrs</artifactId>
-            <version>1.4.0</version>
+            <version>1.6.0</version>
         </dependency>
         <dependency>
             <groupId>org.codehaus.jackson</groupId>
             <artifactId>jackson-xc</artifactId>
-            <version>1.4.0</version>
+            <version>1.6.0</version>
         </dependency>
         <dependency>
             <groupId>org.apache.wink</groupId>

Modified: incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/JAXBCollectionJSONTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/JAXBCollectionJSONTest.java?rev=997531&r1=997530&r2=997531&view=diff
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/JAXBCollectionJSONTest.java
(original)
+++ incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/JAXBCollectionJSONTest.java
Wed Sep 15 22:46:18 2010
@@ -42,6 +42,7 @@ import org.apache.wink.providers.json.JS
 import org.apache.wink.server.internal.servlet.MockServletInvocationTest;
 import org.apache.wink.test.mock.MockRequestConstructor;
 import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider;
+import org.codehaus.jackson.map.SerializationConfig.Feature;
 import org.json.JSONArray;
 import org.springframework.mock.web.MockHttpServletRequest;
 import org.springframework.mock.web.MockHttpServletResponse;
@@ -74,9 +75,9 @@ public class JAXBCollectionJSONTest exte
     private static final String ENTRY_STR_JSON_1    =
                                                         "{\"base\":\"http://b216:8080/reporting/reports\","
+ "\"otherAttributes\":{},"
                                                             + "\"id\":\"toptenvalidators\","
-                                                            + "\"updated\":\"2009-08-31T18:30:02Z\","
+                                                            + "\"updated\":1251743402000,"
                                                             + "\"title\":{\"lang\":\"en\",\"otherAttributes\":{},\"type\":\"text\"},"
-                                                            + "\"published\":\"2009-08-31T18:30:02Z\","
+                                                            + "\"published\":1251743402000,"
                                                             + "\"link\":[{\"otherAttributes\":{},\"rel\":\"alternate\",\"type\":\"application/json\",\"href\":\"http://b216:8080/reporting/reports/toptenvalidators?alt=application/json\"}],"
                                                             + "\"author\":[{\"name\":\"admin
1\"}],"
                                                             + "\"category\":[{\"otherAttributes\":{},\"term\":\"urn:com:systinet:reporting:kind:definition\",\"scheme\":\"urn:com:systinet:reporting:kind\",\"label\":\"report
definition\"}]"
@@ -84,9 +85,9 @@ public class JAXBCollectionJSONTest exte
     private static final String ENTRY_STR_JSON_2    =
                                                         "{\"base\":\"http://b216:8080/reporting/reports\","
+ "\"otherAttributes\":{},"
                                                             + "\"id\":\"toptenvalidators\","
-                                                            + "\"updated\":\"2009-08-31T18:30:02Z\","
+                                                            + "\"updated\":1251743402000,"
                                                             + "\"title\":{\"lang\":\"en\",\"otherAttributes\":{},\"type\":\"text\"},"
-                                                            + "\"published\":\"2009-08-31T18:30:02Z\","
+                                                            + "\"published\":1251743402000,"
                                                             + "\"link\":[{\"otherAttributes\":{},\"rel\":\"alternate\",\"type\":\"application/json\",\"href\":\"http://b216:8080/reporting/reports/toptenvalidators?alt=application/json\"}],"
                                                             + "\"author\":[{\"name\":\"admin
2\"}],"
                                                             + "\"category\":[{\"otherAttributes\":{},\"term\":\"urn:com:systinet:reporting:kind:definition\",\"scheme\":\"urn:com:systinet:reporting:kind\",\"label\":\"report
definition\"}]"
@@ -154,6 +155,9 @@ public class JAXBCollectionJSONTest exte
     @Override
     protected Object[] getSingletons() {
     	JacksonJaxbJsonProvider jacksonProvider = new JacksonJaxbJsonProvider();
+    	jacksonProvider.configure(Feature.WRITE_NULL_MAP_VALUES, Boolean.FALSE);
+    	jacksonProvider.configure(Feature.WRITE_NULL_PROPERTIES, Boolean.FALSE);
+    	jacksonProvider.configure(Feature.WRITE_DATES_AS_TIMESTAMPS, Boolean.TRUE);
         return new Object[] {jacksonProvider};
     }
 

Modified: incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/JacksonJAXBTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/JacksonJAXBTest.java?rev=997531&r1=997530&r2=997531&view=diff
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/JacksonJAXBTest.java
(original)
+++ incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/JacksonJAXBTest.java
Wed Sep 15 22:46:18 2010
@@ -22,7 +22,6 @@ package org.apache.wink.providers.jackso
 
 import java.io.IOException;
 import java.io.StringReader;
-import java.util.GregorianCalendar;
 
 import javax.ws.rs.Consumes;
 import javax.ws.rs.GET;
@@ -30,9 +29,6 @@ import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.xml.bind.JAXBElement;
-import javax.xml.datatype.DatatypeConfigurationException;
-import javax.xml.datatype.DatatypeFactory;
-import javax.xml.datatype.XMLGregorianCalendar;
 
 import org.apache.wink.common.model.atom.AtomEntry;
 import org.apache.wink.common.model.synd.SyndEntry;
@@ -41,6 +37,7 @@ import org.apache.wink.providers.json.JS
 import org.apache.wink.server.internal.servlet.MockServletInvocationTest;
 import org.apache.wink.test.mock.MockRequestConstructor;
 import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider;
+import org.codehaus.jackson.map.SerializationConfig.Feature;
 import org.json.JSONObject;
 import org.springframework.mock.web.MockHttpServletRequest;
 import org.springframework.mock.web.MockHttpServletResponse;
@@ -58,6 +55,7 @@ public class JacksonJAXBTest extends Moc
     @Override
     protected Object[] getSingletons() {
         JacksonJaxbJsonProvider jacksonProvider = new JacksonJaxbJsonProvider();
+        jacksonProvider.configure(Feature.WRITE_NULL_PROPERTIES, Boolean.FALSE);
         return new Object[] {jacksonProvider};
     }
 
@@ -170,6 +168,8 @@ public class JacksonJAXBTest extends Moc
                                                         "application/json");
         MockHttpServletResponse response = invoke(request);
         assertEquals(200, response.getStatus());
+        System.out.println(new JSONObject(ENTRY_JSON).toString(4));
+        System.out.println(new JSONObject(response.getContentAsString()).toString(4));
         assertTrue(JSONUtils.equals(JSONUtils.objectForString(ENTRY_JSON), JSONUtils
             .objectForString(response.getContentAsString())));
     }
@@ -223,9 +223,9 @@ public class JacksonJAXBTest extends Moc
     private static final String ENTRY_STR_JSON      =
                                                         "{\"base\":\"http://b216:8080/reporting/reports\","
+ "\"otherAttributes\":{},"
                                                             + "\"id\":\"toptenvalidators\","
-                                                            + "\"updated\":\"2009-08-31T18:30:02Z\","
+                                                            + "\"updated\":1251743402000,"
                                                             + "\"title\":{\"lang\":\"en\",\"otherAttributes\":{},\"type\":\"text\"},"
-                                                            + "\"published\":\"2009-08-31T18:30:02Z\","
+                                                            + "\"published\":1251743402000,"
                                                             + "\"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\"}]"
@@ -243,29 +243,8 @@ public class JacksonJAXBTest extends Moc
     private static final String ENTRY_JSON_POST;
 
     static {
-
-        GregorianCalendar gCal = new GregorianCalendar();
-        XMLGregorianCalendar xmlGCal = null;
-        try {
-            xmlGCal = DatatypeFactory.newInstance().newXMLGregorianCalendar(gCal);
-        } catch (DatatypeConfigurationException e) {
-            fail("could not construct XMLGregorianCalendar: " + e.getMessage());
-            e.printStackTrace();
-        }
-        String jsonTimeStr = "{";
-        jsonTimeStr += "\"eon\":" + xmlGCal.getEon() + ",";
-        jsonTimeStr += "\"year\":" + xmlGCal.getYear() + ",";
-        jsonTimeStr += "\"day\":" + xmlGCal.getDay() + ",";
-        jsonTimeStr += "\"timezone\":" + xmlGCal.getTimezone() + ",";
-        jsonTimeStr += "\"hour\":" + xmlGCal.getHour() + ",";
-        jsonTimeStr += "\"minute\":" + xmlGCal.getMinute() + ",";
-        jsonTimeStr += "\"second\":" + xmlGCal.getSecond() + ",";
-        jsonTimeStr += "\"millisecond\":" + xmlGCal.getMillisecond();
-        jsonTimeStr += "}";
-
-        ENTRY_JSON = ENTRY_STR_JSON.replaceAll("@TIME_JSON@", jsonTimeStr);
-        ENTRY_JSON_POST = ENTRY_STR_JSON_POST.replaceAll("@TIME_JSON@", jsonTimeStr);
-
+        ENTRY_JSON = ENTRY_STR_JSON;
+        ENTRY_JSON_POST = ENTRY_STR_JSON_POST;
     }
 
 }

Modified: incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/PolymorphicTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/PolymorphicTest.java?rev=997531&r1=997530&r2=997531&view=diff
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/PolymorphicTest.java
(original)
+++ incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/PolymorphicTest.java
Wed Sep 15 22:46:18 2010
@@ -38,8 +38,6 @@ import org.apache.wink.server.internal.s
 import org.apache.wink.test.mock.MockRequestConstructor;
 import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider;
 import org.codehaus.jackson.jaxrs.JacksonJsonProvider;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.xc.JaxbAnnotationIntrospector;
 import org.json.JSONObject;
 import org.junit.Test;
 import org.springframework.mock.web.MockHttpServletRequest;
@@ -56,13 +54,7 @@ public class PolymorphicTest extends Moc
 
     @Override
     protected Object[] getSingletons() {
-        ObjectMapper mapper = new ObjectMapper();
-        JaxbAnnotationIntrospector jaxbIntrospector = new JaxbAnnotationIntrospector();
-        mapper.getSerializationConfig().setAnnotationIntrospector(jaxbIntrospector);
-        mapper.getDeserializationConfig().setAnnotationIntrospector(jaxbIntrospector);
-        jacksonProvider = new JacksonJsonProvider();
-        jacksonProvider.setMapper(mapper);
-        return new Object[]{jacksonProvider};
+        return new Object[]{new JacksonJsonProvider(), new JacksonJaxbJsonProvider()};
     }
 
     @Path("/test/myproperties")
@@ -107,7 +99,7 @@ public class PolymorphicTest extends Moc
         
         // call the provider as though the wink-client was in use on the client side
         InputStream is = new ByteArrayInputStream(response.getContentAsByteArray());
-        MyJAXBObject myJAXBObject = (MyJAXBObject)jacksonProvider.readFrom(Object.class,
MyJAXBObject.class, null, MediaType.APPLICATION_JSON_TYPE, null, is);
+        MyJAXBObject myJAXBObject = (MyJAXBObject)new JacksonJaxbJsonProvider().readFrom(Object.class,
MyJAXBObject.class, null, MediaType.APPLICATION_JSON_TYPE, null, is);
 
         // make sure the Jackson deserializer is using the 'type' property on the XmlElement
annotation in MyJAXBObject
         // confirm Jackson deserialized to expected object type -- support for this was added
in Jackson 1.4



Mime
View raw message