From 9a56d03d39e0a75a0e0e5fe734cca14b30c6c9a1 Mon Sep 17 00:00:00 2001
From: skotambkar <kotambka@amazon.com>
Date: Fri, 14 Aug 2020 14:24:40 -0700
Subject: [PATCH 1/2] adds xml tests to test against characters requiring
 escaping; test cases for xml preamble, comment and CDATA

---
 .../model/restXml/document-structs.smithy     | 43 +++++++++++++++++++
 .../restXml/document-xml-attributes.smithy    | 22 +++++++++-
 2 files changed, 64 insertions(+), 1 deletion(-)

diff --git a/smithy-aws-protocol-tests/model/restXml/document-structs.smithy b/smithy-aws-protocol-tests/model/restXml/document-structs.smithy
index 9aa0bc2e73d..da071172419 100644
--- a/smithy-aws-protocol-tests/model/restXml/document-structs.smithy
+++ b/smithy-aws-protocol-tests/model/restXml/document-structs.smithy
@@ -98,6 +98,49 @@ apply SimpleScalarProperties @httpResponseTests([
             floatValue: 5.5,
             doubleValue: 6.5,
         }
+    },
+    {
+        id: "SimpleScalarPropertiesWithEscapedCharacter",
+        documentation: "Serializes escaped string",
+        protocol: restXml,
+        code: 200,
+        body: """
+              <SimpleScalarPropertiesInputOutput>
+                  <stringValue>&lt;string&gt;</stringValue>
+              </SimpleScalarPropertiesInputOutput>
+              """,
+        bodyMediaType: "application/xml",
+        headers: {
+            "Content-Type": "application/xml",
+            "X-Foo": "Foo",
+        },
+        params: {
+            foo: "Foo",
+            stringValue: "<string>",
+        }
+    },
+    {
+        id: "SimpleScalarPropertiesWithXMLPreamble",
+        documentation: "Serializes simple scalar properties with xml preamble, comments and CDATA",
+        protocol: restXml,
+        code: 200,
+        body: """
+              <?xml version = "1.0" encoding = "UTF-8"?>
+              <SimpleScalarPropertiesInputOutput>
+                  <![CDATA[characters representing CDATA]]>
+                  <stringValue>string</stringValue>
+                  <!--xml comment-->
+              </SimpleScalarPropertiesInputOutput>
+              """,
+        bodyMediaType: "application/xml",
+        headers: {
+            "Content-Type": "application/xml",
+            "X-Foo": "Foo",
+        },
+        params: {
+            foo: "Foo",
+            stringValue: "string",
+        }
     }
 ])
 
diff --git a/smithy-aws-protocol-tests/model/restXml/document-xml-attributes.smithy b/smithy-aws-protocol-tests/model/restXml/document-xml-attributes.smithy
index 32e00c4a970..2b27c900759 100644
--- a/smithy-aws-protocol-tests/model/restXml/document-xml-attributes.smithy
+++ b/smithy-aws-protocol-tests/model/restXml/document-xml-attributes.smithy
@@ -36,7 +36,27 @@ apply XmlAttributes @httpRequestTests([
             foo: "hi",
             attr: "test"
         }
-    }
+    },
+    {
+        id: "XmlAttributesWithEscaping",
+        documentation: "Serializes XML attributes with escaped characters on the synthesized document",
+        protocol: restXml,
+        method: "PUT",
+        uri: "/XmlAttributes",
+        body: """
+              <XmlAttributesInputOutput test="&lt;test&amp;mock&gt;">
+                  <foo>hi</foo>
+              </XmlAttributesInputOutput>
+              """,
+        bodyMediaType: "application/xml",
+        headers: {
+            "Content-Type": "application/xml"
+        },
+        params: {
+            foo: "hi",
+            attr: "<test&mock>"
+        }
+    },
 ])
 
 apply XmlAttributes @httpResponseTests([

From 46545d8d124b083cd2f2a05b1e2b7d06c52e43d4 Mon Sep 17 00:00:00 2001
From: skotambkar <kotambka@amazon.com>
Date: Fri, 14 Aug 2020 16:54:04 -0700
Subject: [PATCH 2/2] adds test for white spaces in xml string value

---
 .../model/restXml/document-structs.smithy     | 67 ++++++++++++++++++-
 1 file changed, 65 insertions(+), 2 deletions(-)

diff --git a/smithy-aws-protocol-tests/model/restXml/document-structs.smithy b/smithy-aws-protocol-tests/model/restXml/document-structs.smithy
index da071172419..af532df9df4 100644
--- a/smithy-aws-protocol-tests/model/restXml/document-structs.smithy
+++ b/smithy-aws-protocol-tests/model/restXml/document-structs.smithy
@@ -59,7 +59,49 @@ apply SimpleScalarProperties @httpRequestTests([
             floatValue: 5.5,
             doubleValue: 6.5,
         }
-    }
+    },
+    {
+        id: "SimpleScalarPropertiesWithEscapedCharacter",
+        documentation: "Serializes string with escaping",
+        protocol: restXml,
+        method: "PUT",
+        uri: "/SimpleScalarProperties",
+        body: """
+              <SimpleScalarPropertiesInputOutput>
+                  <stringValue>&lt;string&gt;</stringValue>
+              </SimpleScalarPropertiesInputOutput>
+              """,
+        bodyMediaType: "application/xml",
+        headers: {
+            "Content-Type": "application/xml",
+            "X-Foo": "Foo",
+        },
+        params: {
+            foo: "Foo",
+            stringValue: "<string>",
+        }
+    },
+    {
+        id: "SimpleScalarPropertiesWithWhiteSpace",
+        documentation: "Serializes string containing white space",
+        protocol: restXml,
+        method: "PUT",
+        uri: "/SimpleScalarProperties",
+        body: """
+              <SimpleScalarPropertiesInputOutput>
+                  <stringValue>string with white    space</stringValue>
+              </SimpleScalarPropertiesInputOutput>
+              """,
+        bodyMediaType: "application/xml",
+        headers: {
+            "Content-Type": "application/xml",
+            "X-Foo": "Foo",
+        },
+        params: {
+            foo: "Foo",
+            stringValue: "string with white    space",
+        }
+    },
 ])
 
 apply SimpleScalarProperties @httpResponseTests([
@@ -101,7 +143,7 @@ apply SimpleScalarProperties @httpResponseTests([
     },
     {
         id: "SimpleScalarPropertiesWithEscapedCharacter",
-        documentation: "Serializes escaped string",
+        documentation: "Serializes string with escaping",
         protocol: restXml,
         code: 200,
         body: """
@@ -141,6 +183,27 @@ apply SimpleScalarProperties @httpResponseTests([
             foo: "Foo",
             stringValue: "string",
         }
+    },
+    {
+        id: "SimpleScalarPropertiesWithWhiteSpace",
+        documentation: "Serializes string containing white space",
+        protocol: restXml,
+        code: 200,
+        body: """
+              <?xml version = "1.0" encoding = "UTF-8"?>
+              <SimpleScalarPropertiesInputOutput>
+                  <stringValue>string with white    space</stringValue>
+              </SimpleScalarPropertiesInputOutput>
+              """,
+        bodyMediaType: "application/xml",
+        headers: {
+            "Content-Type": "application/xml",
+            "X-Foo": "Foo",
+        },
+        params: {
+            foo: "Foo",
+            stringValue: "string with white    space",
+        }
     }
 ])