-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Protocol tests generation stub and cmake
- Loading branch information
1 parent
9f269b4
commit fa7096d
Showing
20 changed files
with
843 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0. | ||
# | ||
|
||
function(add_protocol_tests) | ||
set(PROTOCOL_TESTS_LOG "") | ||
# Add test clients, which are just like a regular SDK client, but must not be installed. | ||
file(GLOB subdirs LIST_DIRECTORIES true "${CMAKE_SOURCE_DIR}/generated/protocol-tests/test-clients/*") | ||
foreach(subdir ${subdirs}) | ||
if(EXISTS "${subdir}/CMakeLists.txt") | ||
add_subdirectory(${subdir} EXCLUDE_FROM_ALL) | ||
endif() | ||
endforeach() | ||
|
||
# Add tests | ||
file(GLOB protoTestTypes LIST_DIRECTORIES true "${CMAKE_SOURCE_DIR}/generated/protocol-tests/tests/*") | ||
foreach(protoTestType ${protoTestTypes}) | ||
file(GLOB subdirs LIST_DIRECTORIES true ${protoTestType}/*) | ||
foreach(subdir ${subdirs}) | ||
if(EXISTS "${subdir}/CMakeLists.txt") | ||
add_subdirectory(${subdir}) | ||
|
||
get_filename_component(testGroup ${protoTestType} NAME) | ||
get_filename_component(testName ${subdir} NAME) | ||
list(APPEND PROTOCOL_TESTS_LOG "${testGroup}/${testName}") | ||
endif() | ||
endforeach() | ||
endforeach() | ||
|
||
message(STATUS "Protocol tests: ${PROTOCOL_TESTS_LOG}") | ||
endfunction() | ||
|
||
if (ENABLE_PROTOCOL_TESTS) | ||
add_protocol_tests() | ||
endif () |
33 changes: 33 additions & 0 deletions
33
...n/java/com/amazonaws/util/awsclientgenerator/domainmodels/c2j_protocol_test/C2jGiven.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
|
||
package com.amazonaws.util.awsclientgenerator.domainmodels.c2j_protocol_test; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class C2jGiven { | ||
@Data | ||
public static class C2jGivenHttp { | ||
private String method; | ||
private String requestUri; | ||
} | ||
|
||
@Data | ||
public static class C2jGivenInput { | ||
private String shape; | ||
private String locationName; | ||
} | ||
|
||
@Data | ||
public static class C2jGivenEndpoint { | ||
private String hostPrefix; | ||
} | ||
|
||
private String name; | ||
private C2jGivenHttp http; | ||
private C2jGivenInput input; | ||
private C2jGivenEndpoint endpoint; | ||
} |
43 changes: 43 additions & 0 deletions
43
.../amazonaws/util/awsclientgenerator/domainmodels/c2j_protocol_test/C2jInputSerialized.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
|
||
package com.amazonaws.util.awsclientgenerator.domainmodels.c2j_protocol_test; | ||
|
||
import lombok.Data; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@Data | ||
public class C2jInputSerialized { | ||
/** | ||
* The HTTP method. | ||
*/ | ||
private String method; | ||
/** | ||
* The HTTP body as a string. | ||
*/ | ||
private String body; | ||
/** | ||
* The uri path and querystring of the request. | ||
*/ | ||
private String uri; | ||
/** | ||
* The URL host of the request. | ||
*/ | ||
private String host; | ||
/** | ||
* Any HTTP headers for the HTTP request. | ||
*/ | ||
private Map<String, String> headers; | ||
/** | ||
* A list of header names that must not exist in the HTTP Request. | ||
*/ | ||
private List<String> forbidHeaders; | ||
/** | ||
* A list of header names that must exist in the HTTP Request. | ||
*/ | ||
private List<String> requireHeaders; | ||
} |
35 changes: 35 additions & 0 deletions
35
...om/amazonaws/util/awsclientgenerator/domainmodels/c2j_protocol_test/C2jInputTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
|
||
package com.amazonaws.util.awsclientgenerator.domainmodels.c2j_protocol_test; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import lombok.Data; | ||
|
||
@Data | ||
public class C2jInputTestCase { | ||
/** | ||
* A test case id. | ||
*/ | ||
private String id; | ||
/** | ||
* A test case description. | ||
*/ | ||
private String description; | ||
/** | ||
* This corresponds to the JSON object that would define an operation in the service's JSON model. | ||
* Valid keys include http, input, endpoint, and name. | ||
*/ | ||
private C2jGiven given; | ||
/** | ||
* The input parameters a user would provide. | ||
*/ | ||
private JsonNode params; | ||
|
||
/** | ||
* The expected serialized HTTP request. | ||
*/ | ||
private C2jInputSerialized serialized; | ||
} |
38 changes: 38 additions & 0 deletions
38
...m/amazonaws/util/awsclientgenerator/domainmodels/c2j_protocol_test/C2jInputTestSuite.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
|
||
package com.amazonaws.util.awsclientgenerator.domainmodels.c2j_protocol_test; | ||
|
||
|
||
import com.amazonaws.util.awsclientgenerator.domainmodels.c2j.C2jMetadata; | ||
import com.amazonaws.util.awsclientgenerator.domainmodels.c2j.C2jShape; | ||
import lombok.Data; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@Data | ||
public class C2jInputTestSuite { | ||
/** | ||
* A description of the tests | ||
*/ | ||
private String description; | ||
/** | ||
* The top level metadata that would correspond to the metadata key in the service's JSON model. | ||
*/ | ||
private C2jMetadata metadata; | ||
/** | ||
* An URL string the test cases must use when constructing the request's URL endpoint. | ||
*/ | ||
private String clientEndpoint; | ||
/** | ||
* A JSON object of shapes. This would correspond to the top level shapes key in the service's JSON model. | ||
*/ | ||
private Map<String, C2jShape> shapes; | ||
/** | ||
* a JSON list of test cases. | ||
*/ | ||
private List<C2jInputTestCase> cases; | ||
} |
17 changes: 17 additions & 0 deletions
17
...m/amazonaws/util/awsclientgenerator/domainmodels/c2j_protocol_test/C2jOutputResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
|
||
package com.amazonaws.util.awsclientgenerator.domainmodels.c2j_protocol_test; | ||
|
||
import lombok.Data; | ||
|
||
import java.util.Map; | ||
|
||
@Data | ||
public class C2jOutputResponse { | ||
int status_code; | ||
private Map<String, String> headers; | ||
private String body; | ||
} |
48 changes: 48 additions & 0 deletions
48
...m/amazonaws/util/awsclientgenerator/domainmodels/c2j_protocol_test/C2jOutputTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
|
||
package com.amazonaws.util.awsclientgenerator.domainmodels.c2j_protocol_test; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import lombok.Data; | ||
|
||
@Data | ||
public class C2jOutputTestCase { | ||
/** | ||
* A test case id. | ||
*/ | ||
private String id; | ||
/** | ||
* A test case description. | ||
*/ | ||
private String description; | ||
/** | ||
* This corresponds to the JSON object that would define an operation in the service's JSON model. | ||
* Valid keys include http, input, endpoint, and name. | ||
*/ | ||
private C2jGiven given; | ||
/** | ||
* A JSON hash representing the structure of the parsed response. Either this or error (not both) must appear in the test case. | ||
*/ | ||
private JsonNode result; | ||
/** | ||
* A JSON hash representing the structure of the parsed error response. Either this or result (not both) must appear in the test case. | ||
*/ | ||
private JsonNode error; | ||
/** | ||
* A string specifying the AWS error code extracted from the response. Corresponds to the error shape to be unmarshalled and | ||
* should always be set, even when the shape can not be found. Must be present when the error key is present. | ||
*/ | ||
private String errorCode; | ||
/** | ||
* A string specifying the error message extracted from the response. | ||
* Should be able to be extracted even when an error shape is not unmarshalled. May only be present when the error key is present. | ||
*/ | ||
private String errorMessage; | ||
/** | ||
* The HTTP response to be parsed | ||
*/ | ||
private C2jOutputResponse response; | ||
} |
37 changes: 37 additions & 0 deletions
37
.../amazonaws/util/awsclientgenerator/domainmodels/c2j_protocol_test/C2jOutputTestSuite.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
|
||
package com.amazonaws.util.awsclientgenerator.domainmodels.c2j_protocol_test; | ||
|
||
import com.amazonaws.util.awsclientgenerator.domainmodels.c2j.C2jMetadata; | ||
import com.amazonaws.util.awsclientgenerator.domainmodels.c2j.C2jShape; | ||
import lombok.Data; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@Data | ||
public class C2jOutputTestSuite { | ||
/** | ||
* A description of the tests | ||
*/ | ||
private String description; | ||
/** | ||
* The top level metadata that would correspond to the metadata key in the service's JSON model. | ||
*/ | ||
private C2jMetadata metadata; | ||
/** | ||
* A URL string the test cases must use when constructing the request's URL endpoint. | ||
*/ | ||
private String clientEndpoint; | ||
/** | ||
* A JSON object of C2jShapes. This would correspond to the top level C2jShapes key in the service's JSON model. | ||
*/ | ||
private Map<String, C2jShape> shapes; | ||
/** | ||
* a JSON list of test cases. | ||
*/ | ||
private List<C2jOutputTestCase> cases; | ||
} |
26 changes: 26 additions & 0 deletions
26
...va/com/amazonaws/util/awsclientgenerator/domainmodels/c2j_protocol_test/C2jTestSuite.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
|
||
package com.amazonaws.util.awsclientgenerator.domainmodels.c2j_protocol_test; | ||
|
||
import com.amazonaws.util.awsclientgenerator.domainmodels.c2j.C2jMetadata; | ||
import com.amazonaws.util.awsclientgenerator.domainmodels.c2j.C2jShape; | ||
import lombok.Data; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@Data | ||
public class C2jTestSuite { | ||
private String name; | ||
private String serviceToUse; | ||
public enum TestSuiteType { | ||
INPUT, | ||
OUTPUT | ||
} | ||
TestSuiteType type; // only can be present. | ||
private List<C2jInputTestSuite> inputTestSuites; | ||
private List<C2jOutputTestSuite> outputTestSuites; | ||
} |
35 changes: 35 additions & 0 deletions
35
...mazonaws/util/awsclientgenerator/domainmodels/c2j_protocol_test/JsonNodeDeserializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
|
||
package com.amazonaws.util.awsclientgenerator.domainmodels.c2j; | ||
|
||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.google.gson.JsonDeserializationContext; | ||
import com.google.gson.JsonDeserializer; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonParseException; | ||
|
||
import java.lang.reflect.Type; | ||
|
||
/** | ||
* A helper for gson parser to deserialize raw JSON entry in the protocol test definition to a "Jackson.JsonNode" | ||
*/ | ||
public class JsonNodeDeserializer implements JsonDeserializer<JsonNode> { | ||
@Override | ||
public JsonNode deserialize(JsonElement jsonElement, Type type, | ||
JsonDeserializationContext context) throws JsonParseException { | ||
ObjectMapper objectMapper = new ObjectMapper(); | ||
JsonNode jsonNode = null; | ||
try { | ||
jsonNode = objectMapper.readValue(jsonElement.getAsJsonObject().toString(), JsonNode.class); | ||
} catch (JsonProcessingException e) { | ||
throw new RuntimeException(e); | ||
} | ||
return jsonNode; | ||
} | ||
} |
Oops, something went wrong.