Skip to content

Commit

Permalink
Add AWS REST XML protocol tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mtdowling committed Jan 13, 2020
1 parent 96a684b commit a35fcfe
Show file tree
Hide file tree
Showing 16 changed files with 3,150 additions and 0 deletions.
8 changes: 8 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
rootProject.name = "smithy"
include(":smithy-aws-traits")
include(":smithy-aws-apigateway-openapi")
include(":smithy-aws-protocol-tests")
include(":smithy-cli")
include(":smithy-codegen-core")
include(":smithy-codegen-freemarker")
Expand All @@ -13,3 +14,10 @@ include(":smithy-jsonschema")
include(":smithy-openapi")
include(":smithy-utils")
include(":smithy-protocol-test-traits")

pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
}
}
27 changes: 27 additions & 0 deletions smithy-aws-protocol-tests/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

description = "Defines protocol tests for AWS HTTP protocols."
extra["displayName"] = "Smithy :: AWS :: Protocol Tests"
extra["moduleName"] = "software.amazon.smithy.aws.protocoltests"

plugins {
id("software.amazon.smithy").version("0.4.2")
}

dependencies {
api(project(":smithy-protocol-test-traits"))
api(project(":smithy-aws-traits"))
}
255 changes: 255 additions & 0 deletions smithy-aws-protocol-tests/model/rest-xml/document-lists.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,255 @@
// This file defines test cases that serialize lists in XML documents.

$version: "0.5.0"

namespace aws.protocols.tests.restxml

use smithy.test#httpRequestTests
use smithy.test#httpResponseTests

/// This test case serializes XML lists for the following cases for both
/// input and output:
///
/// 1. Normal XML lists.
/// 2. Normal XML sets.
/// 3. XML lists of lists.
/// 4. XML lists with @xmlName on its members
/// 5. Flattened XML lists.
/// 6. Flattened XML lists with @xmlName.
/// 7. Lists of structures.
@idempotent
@http(uri: "/XmlLists", method: "PUT")
operation XmlLists(XmlListsInputOutput) -> XmlListsInputOutput

apply XmlLists @httpRequestTests([
{
id: "XmlLists",
description: "Serializes XML lists",
protocol: "aws.rest-xml",
method: "PUT",
uri: "/XmlLists",
body: """
<XmlListsInputOutput>
<stringList>
<member>foo</member>
<member>bar</member>
</stringList>
<stringSet>
<member>foo</member>
<member>bar</member>
</stringSet>
<integerList>
<member>1</member>
<member>2</member>
</integerList>
<booleanList>
<member>true</member>
<member>false</member>
</booleanList>
<timestampList>
<member>2014-04-29T18:30:38Z</member>
<member>2014-04-29T18:30:38Z</member>
</timestampList>
<enumList>
<member>Foo</member>
<member>0</member>
</enumList>
<nestedStringList>
<member>
<member>foo</member>
<member>bar</member>
</member>
<member>
<member>baz</member>
<member>qux</member>
</member>
<nestedStringList>
<renamed>
<item>foo</item>
<item>bar</item>
</renamed>
<flattenedList>hi</flattenedList>
<flattenedList>bye</flattenedList>
<customName>yep</customName>
<customName>nope</customName>
<myStructureList>
<item>
<value>1</value>
<other>2</other>
</item>
<item>
<value>3</value>
<other>4</other>
</item>
</myStructureList>
</XmlListsInputOutput>
""",
bodyMediaType: "application/xml",
headers: {
"Content-Type": "application/xml"
},
params: {
stringList: ["foo", "bar"],
stringSet: ["foo", "bar"],
integerList: [1, 2],
booleanList: [true, false],
timestampList: [1398796238, 1398796238],
enumList: ["Foo", "0"],
nestedStringList: [["foo", "bar"], ["baz", "qux"]],
renamedListMembers: ["foo", "bar"],
flattenedList: ["hi", "bye"],
flattenedList2: ["yep", "nope"],
structureList: [
{
a: "1",
b: "2",
},
{
a: "3",
b: "4",
}
]
}
}
])

apply XmlLists @httpResponseTests([
{
id: "XmlLists",
description: "Serializes XML lists",
protocol: "aws.rest-xml",
code: 200,
body: """
<XmlListsInputOutput>
<stringList>
<member>foo</member>
<member>bar</member>
</stringList>
<stringSet>
<member>foo</member>
<member>bar</member>
</stringSet>
<integerList>
<member>1</member>
<member>2</member>
</integerList>
<booleanList>
<member>true</member>
<member>false</member>
</booleanList>
<timestampList>
<member>2014-04-29T18:30:38Z</member>
<member>2014-04-29T18:30:38Z</member>
</timestampList>
<enumList>
<member>Foo</member>
<member>0</member>
</enumList>
<nestedStringList>
<member>
<member>foo</member>
<member>bar</member>
</member>
<member>
<member>baz</member>
<member>qux</member>
</member>
<nestedStringList>
<renamed>
<item>foo</item>
<item>bar</item>
</renamed>
<flattenedList>hi</flattenedList>
<flattenedList>bye</flattenedList>
<customName>yep</customName>
<customName>nope</customName>
<myStructureList>
<item>
<value>1</value>
<other>2</other>
</item>
<item>
<value>3</value>
<other>4</other>
</item>
</myStructureList>
</XmlListsInputOutput>
""",
bodyMediaType: "application/xml",
headers: {
"Content-Type": "application/xml"
},
params: {
stringList: ["foo", "bar"],
stringSet: ["foo", "bar"],
integerList: [1, 2],
booleanList: [true, false],
timestampList: [1398796238, 1398796238],
enumList: ["Foo", "0"],
nestedStringList: [["foo", "bar"], ["baz", "qux"]],
renamedListMembers: ["foo", "bar"],
flattenedList: ["hi", "bye"],
flattenedList2: ["yep", "nope"],
structureList: [
{
a: "1",
b: "2",
},
{
a: "3",
b: "4",
}
]
}
}
])

structure XmlListsInputOutput {
stringList: StringList,

stringSet: StringSet,

integerList: IntegerList,

booleanList: BooleanList,

timestampList: TimestampList,

enumList: FooEnumList,

nestedStringList: NestedStringList,

@xmlName("renamed")
renamedListMembers: RenamedListMembers,

@xmlFlattened
// The xmlname on the targeted list is ignored, and the member name is used.
flattenedList: RenamedListMembers,

@xmlName("customName")
@xmlFlattened
// the xmlName trait on the targeted list's member is ignored when
// serializing flattened lists in structures.
flattenedList2: RenamedListMembers,

@xmlName("myStructureList")
structureList: StructureList
}

list RenamedListMembers {
@xmlName("item")
member: String,
}

list StructureList {
@xmlName("item")
member: StructureListMember,
}

structure StructureListMember {
@xmlName("value")
a: String,

@xmlName("other")
b: String,
}
Loading

0 comments on commit a35fcfe

Please sign in to comment.