|
1 | 1 | /***
|
2 | 2 | * ==++==
|
3 | 3 | *
|
4 |
| -* Copyright (c) Microsoft Corporation. All rights reserved. |
| 4 | +* Copyright (c) Microsoft Corporation. All rights reserved. |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License");
|
6 | 6 | * you may not use this file except in compliance with the License.
|
7 | 7 | * You may obtain a copy of the License at
|
8 | 8 | * http://www.apache.org/licenses/LICENSE-2.0
|
9 |
| -* |
| 9 | +* |
10 | 10 | * Unless required by applicable law or agreed to in writing, software
|
11 | 11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
12 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16 | 16 | * ==--==
|
17 | 17 | * =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
|
18 | 18 | *
|
19 |
| -* multiple_requests.cpp |
20 |
| -* |
21 | 19 | * Tests cases for multiple requests and responses from an http_client.
|
22 | 20 | *
|
23 | 21 | * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
@@ -55,67 +53,6 @@ static void initialize_data(std::string *data_arrays, const size_t count)
|
55 | 53 | SUITE(multiple_requests)
|
56 | 54 | {
|
57 | 55 |
|
58 |
| -TEST_FIXTURE(uri_address, single_tcp_connection) |
59 |
| -{ |
60 |
| - test_http_server::scoped_server scoped(m_uri); |
61 |
| - http_client_config config; |
62 |
| - config.set_guarantee_order(true); |
63 |
| - http_client client(m_uri, config); |
64 |
| - |
65 |
| - const size_t num_requests = 20; |
66 |
| - std::string request_bodies[num_requests]; |
67 |
| - initialize_data(request_bodies, num_requests); |
68 |
| - const method method = methods::PUT; |
69 |
| - const web::http::status_code code = status_codes::OK; |
70 |
| - |
71 |
| - // setup to handle requests on the server side. |
72 |
| - // If any of the requests come in before the response is sent the test fails. |
73 |
| - auto requests = scoped.server()->next_requests(num_requests); |
74 |
| - volatile unsigned long response_sent = 0; |
75 |
| - requests[0].then([&](test_request *request) |
76 |
| - { |
77 |
| - http_asserts::assert_test_request_equals(request, method, U("/"), U("text/plain"), to_string_t(request_bodies[0])); |
78 |
| - // wait a bit to see if the other requests will come. |
79 |
| - os_utilities::sleep(500); |
80 |
| - os_utilities::interlocked_increment(&response_sent); |
81 |
| - VERIFY_ARE_EQUAL(0u, request->reply(code)); |
82 |
| - }); |
83 |
| - for(size_t i = 1; i < num_requests; ++i) |
84 |
| - { |
85 |
| - requests[i].then([i, &response_sent, &code, &method, &request_bodies](test_request *request) |
86 |
| - { |
87 |
| - if(os_utilities::interlocked_increment(&response_sent) == 1) |
88 |
| - { |
89 |
| - VERIFY_IS_TRUE(false); |
90 |
| - } |
91 |
| - http_asserts::assert_test_request_equals(request, method, U("/"), U("text/plain"), to_string_t(request_bodies[i])); |
92 |
| - VERIFY_ARE_EQUAL(0u, request->reply(code)); |
93 |
| - }); |
94 |
| - } |
95 |
| - |
96 |
| - // send requests |
97 |
| - std::vector<pplx::task<http_response>> responses; |
98 |
| - for(size_t i = 0; i < num_requests; ++i) |
99 |
| - { |
100 |
| - http_request msg(method); |
101 |
| - msg.set_body(request_bodies[i]); |
102 |
| - responses.push_back(client.request(msg)); |
103 |
| - } |
104 |
| - |
105 |
| - // wait for requests. |
106 |
| - for(size_t i = 0; i < num_requests; ++i) |
107 |
| - { |
108 |
| - try |
109 |
| - { |
110 |
| - http_asserts::assert_response_equals(responses[i].get(), code); |
111 |
| - } |
112 |
| - catch (...) |
113 |
| - { |
114 |
| - VERIFY_IS_FALSE(false); |
115 |
| - } |
116 |
| - } |
117 |
| -} |
118 |
| - |
119 | 56 | TEST_FIXTURE(uri_address, requests_with_data)
|
120 | 57 | {
|
121 | 58 | test_http_server::scoped_server scoped(m_uri);
|
@@ -147,7 +84,7 @@ TEST_FIXTURE(uri_address, requests_with_data)
|
147 | 84 | http_asserts::assert_test_request_equals(request, method, U("/"), U("text/plain"), to_string_t(request_body));
|
148 | 85 | VERIFY_ARE_EQUAL(0u, request->reply(code));
|
149 | 86 | }
|
150 |
| - |
| 87 | + |
151 | 88 | // wait for requests.
|
152 | 89 | for(size_t i = 0; i < num_requests; ++i)
|
153 | 90 | {
|
@@ -190,7 +127,7 @@ TEST_FIXTURE(uri_address, responses_with_data)
|
190 | 127 | http_asserts::assert_test_request_equals(request, method, U("/"));
|
191 | 128 | VERIFY_ARE_EQUAL(0u, request->reply(code, U(""), headers, request_body));
|
192 | 129 | }
|
193 |
| - |
| 130 | + |
194 | 131 | // wait for requests.
|
195 | 132 | for(size_t i = 0; i < num_requests; ++i)
|
196 | 133 | {
|
|
0 commit comments