From c836a8905e008246e4aa678a95f55e32c2e62b63 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Mon, 6 Feb 2017 11:48:19 -0500 Subject: [PATCH] Add test for #551 --- .../uhn/fhir/parser/XmlParserDstu3Test.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/XmlParserDstu3Test.java b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/XmlParserDstu3Test.java index 32921ead1ca..35db996195d 100644 --- a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/XmlParserDstu3Test.java +++ b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/XmlParserDstu3Test.java @@ -25,7 +25,9 @@ import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.util.*; +import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.StringUtils; import org.custommonkey.xmlunit.Diff; import org.custommonkey.xmlunit.XMLUnit; import org.hamcrest.collection.IsEmptyCollection; @@ -76,6 +78,24 @@ public class XmlParserDstu3Test { ourCtx.setNarrativeGenerator(null); } + /** + * See #551 + */ + @Test + public void testXmlLargeAttribute() { + String largeString = StringUtils.leftPad("", (int) FileUtils.ONE_MB, 'A'); + + Patient p = new Patient(); + p.addName().setFamily(largeString); + + String encoded = ourCtx.newXmlParser().encodeResourceToString(p); + + p = ourCtx.newXmlParser().parseResource(Patient.class, encoded); + + assertEquals(largeString, p.getNameFirstRep().getFamily()); + } + + /** * See #544 */