Permalink
Browse files

Fixed [Issue-29]

  • Loading branch information...
1 parent 5d269fd commit 34beb478c9c3bc015a1fc76c33458e99197b6d7c @cowtowncoder cowtowncoder committed Jul 18, 2012
View
@@ -10,10 +10,18 @@ Description:
Fixes:
+* [Issue-29]: Binary value not cleared, leading to duplicated binary data
+ for POJOs.
+ (reported by 'farfalena'@git)
+
------------------------------------------------------------------------
=== History: ===
------------------------------------------------------------------------
+2.0.4 (26-Jun-2012)
+
+no new fixes, dependencies to core components updated.
+
2.0.3 (15-Jun-2012)
Fixes:
@@ -322,6 +322,7 @@ public boolean isExpectedStartArrayToken() {
@Override
public JsonToken nextToken() throws IOException, JsonParseException
{
+ _binaryValue = null; // to fix [Issue-29]
if (_nextToken != null) {
JsonToken t = _nextToken;
_currToken = t;
@@ -345,7 +346,6 @@ public JsonToken nextToken() throws IOException, JsonParseException
}
return t;
}
-
int token = _xmlTokens.next();
/* Need to have a loop just because we may have to eat/convert
@@ -0,0 +1,43 @@
+package com.fasterxml.jackson.dataformat.xml;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class TestBinaryData extends XmlTestBase
+{
+ public static class Data {
+ public byte[] bytes;
+ }
+
+ public static class TwoData {
+ public Data data1;
+ public Data data2;
+ }
+
+ /*
+ /**********************************************************
+ /* Unit tests
+ /**********************************************************
+ */
+
+ private final XmlMapper MAPPER = new XmlMapper();
+
+ // for [https://github.com/FasterXML/jackson-dataformat-xml/issues/29]
+ public void testTwoBinaryProps() throws Exception
+ {
+ /* Hmmh. Looks like XmlMapper has some issues with convertValue:
+ * should investigate at some point. But not now...
+ */
+ final ObjectMapper jsonMapper = new ObjectMapper();
+ String BIN1 = jsonMapper.convertValue("Hello".getBytes("UTF-8"), String.class);
+ String BIN2 = jsonMapper.convertValue("world!!".getBytes("UTF-8"), String.class);
+ String xml =
+ "<TwoData>" +
+ "<data1><bytes>" + BIN1 + "</bytes></data1>" +
+ "<data2><bytes>" + BIN2 + "</bytes></data2>" +
+ "</TwoData>";
+
+ TwoData two = new XmlMapper().readValue(xml, TwoData.class);
+ assertEquals("Hello", new String(two.data1.bytes, "UTF-8"));
+ assertEquals("world!!", new String(two.data2.bytes, "UTF-8"));
+ }
+}

0 comments on commit 34beb47

Please sign in to comment.