Skip to content

Commit

Permalink
Add passing test for #427
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Nov 10, 2020
1 parent 7fdb1a4 commit 57aa311
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
Expand Down Expand Up @@ -32,6 +34,20 @@ static class EmptyStrings25
public String b = "NOT SET";
}

// [dataformat-xml#427]
static class Stuff427 {
String str;

@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
public Stuff427(String s) { str = s; }
}

static class Product427 {
Stuff427 stuff;

public Product427(@JsonProperty("stuff") Stuff427 s) { stuff = s; }
}

/*
/**********************************************************
/* Test methods
Expand Down Expand Up @@ -89,4 +105,16 @@ public void testEmptyStringFromElemAndAttr() throws Exception
assertEquals("", ob.a);
assertEquals("", ob.b);
}

// [dataformat-xml#427]
public void testEmptyIssue427() throws Exception
{
String xml = "<product><stuff></stuff></product>";

Product427 product = MAPPER.readValue(xml, Product427.class);

assertNotNull(product);
assertNotNull(product.stuff);
assertEquals("", product.stuff.str);
}
}

0 comments on commit 57aa311

Please sign in to comment.