Skip to content

Commit

Permalink
Fix for #460 (actually just verification test, release notes; real fi…
Browse files Browse the repository at this point in the history
…x in jackson-databind)
  • Loading branch information
cowtowncoder committed Mar 27, 2021
1 parent 2874ddc commit 847f707
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 3 deletions.
1 change: 1 addition & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Project: jackson-dataformat-xml

#456: Fix JsonAlias with unwrapped lists
(contributed by Westin M)
#460: Deserialization from blank (not empty) String fails for Collections

2.12.2 (03-Mar-2021)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// for [dataformat-xml#441]
public class JsonNodeBasicSer441Test extends XmlTestBase
{
final private ObjectMapper XML_MAPPER = newMapper();
private final ObjectMapper XML_MAPPER = newMapper();

public void testSimpleNode() throws Exception
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.fasterxml.jackson.dataformat.xml.failing;

import java.util.List;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;

public class ListDeser458Test extends XmlTestBase
{
static class Channel458 {
public String channelId;
}

static class ChannelSet458 {
public String setId;

// is default but just for readability
@JacksonXmlElementWrapper(useWrapping = true)
public List<Channel458> channels;
}

private final ObjectMapper XML_MAPPER = newMapper();

public void testIssue458() throws Exception
{
String input = "<ChannelSet458>\n" +
"<setId>2</setId>\n" +
"<channels>\n" +
"</channels>\n" +
"</ChannelSet458>";
ChannelSet458 inputProxyChannelStatus = XML_MAPPER.readValue(input, ChannelSet458.class);
assertEquals("List should be empty", 0,
inputProxyChannelStatus.channels.size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,27 @@ static class Entry
static class Value319 {
public Long orderId, orderTypeId;
}


// [dataformat-xml#460]
static class Channel460 {
public String channelId;
}

static class ChannelSet460 {
public String setId;

// is default but just for readability
@JacksonXmlElementWrapper(useWrapping = true)
public List<Channel460> channels;
}

/*
/**********************************************************
/* Test methods
/**********************************************************
*/

private final XmlMapper MAPPER = new XmlMapper();
private final XmlMapper MAPPER = newMapper();

// [dataformat-xml#124]
public void test124() throws Exception {
Expand Down Expand Up @@ -101,4 +114,17 @@ public void testEmptyListAsNull435() throws Exception
});
assertNull(result);
}

// [dataformat-xml#460]
public void testWrappedEmptyListWithWhitespace458() throws Exception
{
String input = "<ChannelSet460>\n" +
"<setId>2</setId>\n" +
"<channels>\n" +
"</channels>\n" +
"</ChannelSet460>";
ChannelSet460 set = MAPPER.readValue(input, ChannelSet460.class);
assertEquals("List should be empty", 0,
set.channels.size());
}
}

0 comments on commit 847f707

Please sign in to comment.