[jackson-jaxrs-providers] 92/162: Fix issues with XML unit tests, related to fixes in XML module for 2.3

Timo Aaltonen tjaalton at moszumanska.debian.org
Mon Sep 8 22:16:31 UTC 2014


This is an automated email from the git hooks/post-receive script.

tjaalton pushed a commit to branch master
in repository jackson-jaxrs-providers.

commit 1091635a497a3d541caa136663960523c26a4141
Author: Tatu Saloranta <tatu.saloranta at iki.fi>
Date:   Wed Oct 9 20:37:33 2013 -0700

    Fix issues with XML unit tests, related to fixes in XML module for 2.3
---
 .../jackson/jaxrs/xml/TestJacksonFeaturesWithXML.java        | 11 ++++++++---
 .../java/com/fasterxml/jackson/jaxrs/xml/TestRootType.java   | 12 ++++++++----
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestJacksonFeaturesWithXML.java b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestJacksonFeaturesWithXML.java
index 41df5f0..321a9f3 100644
--- a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestJacksonFeaturesWithXML.java
+++ b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestJacksonFeaturesWithXML.java
@@ -56,10 +56,14 @@ public class TestJacksonFeaturesWithXML extends JaxrsTestBase
         JacksonFeatures feats = m.getAnnotation(JacksonFeatures.class);
         assertNotNull(feats); // just a sanity check
 
-        // when (extra) wrapping enabled, we get:
+        /* 09-Oct-2013, tatu: As of 2.3, XML backend does NOT add extra wrapping
+         *   any more: it is only added to JSON where it is needed; but not
+         *   to XML which always basically uses wrapping.
+         */
         prov.writeTo(bean, bean.getClass(), bean.getClass(), new Annotation[] { feats },
                 MediaType.APPLICATION_JSON_TYPE, null, out);
-        assertEquals("<Bean><Bean><a>3</a></Bean></Bean>", out.toString("UTF-8"));
+        //
+        assertEquals("<Bean><a>3</a></Bean>", out.toString("UTF-8"));
 
         // but without, not:
         out.reset();
@@ -77,7 +81,8 @@ public class TestJacksonFeaturesWithXML extends JaxrsTestBase
         // should still enable root-wrapping
         prov.writeTo(bean, bean.getClass(), bean.getClass(), m.getAnnotations(),
                 MediaType.APPLICATION_JSON_TYPE, null, out);
-        assertEquals("<Bean><Bean><a>3</a></Bean></Bean>", out.toString("UTF-8"));
+        // as per above, no extra wrapping for XML, in 2.3:
+        assertEquals("<Bean><a>3</a></Bean>", out.toString("UTF-8"));
     }
     
     // [Issue-2], deserialization
diff --git a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestRootType.java b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestRootType.java
index a5664c2..7472406 100644
--- a/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestRootType.java
+++ b/xml/src/test/java/com/fasterxml/jackson/jaxrs/xml/TestRootType.java
@@ -26,15 +26,19 @@ public class TestRootType
     {
         JacksonXMLProvider prov = new JacksonXMLProvider();
         TypeReference<?> ref = new TypeReference<List<Bean>>(){};
-
-        Bean bean = new Bean();
         ArrayList<Bean> list = new ArrayList<Bean>();
-        list.add(bean);
+        list.add(new Bean());
+        list.add(new Bean());
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         MediaType mt = MediaType.APPLICATION_JSON_TYPE;
         prov.writeTo(list, List.class, ref.getType(), new Annotation[0], mt, null, out);
 
         String xml = out.toString("UTF-8");
-        assertEquals("<List><bean><a>3</a></bean></List>", xml);
+        /* 09-Oct-2013, tatu: With 2.2, this produced "unwrapped" output; but
+         *   with 2.3 it should use same defaults as XML module. So 'wrappers'
+         *   are used for Collections, unless explicitly disabled.
+         */
+        assertEquals("<List><item><bean><a>3</a></bean></item>"
+                +"<item><bean><a>3</a></bean></item></List>", xml);
     }
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jackson-jaxrs-providers.git



More information about the pkg-java-commits mailing list