Skip to content

Commit f0648c5

Browse files
committed
Updating set_body_stream_exception test case to work around file stream issue.
1 parent f597883 commit f0648c5

File tree

4 files changed

+35
-27
lines changed

4 files changed

+35
-27
lines changed

Release/include/cpprest/containerstream.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,9 @@ namespace Concurrency { namespace streams {
325325
{
326326
pos_type beg(0);
327327

328-
// Inorder to support relative seeking from the end postion we need to fix an end position.
328+
// In order to support relative seeking from the end position we need to fix an end position.
329329
// Technically, there is no end for the stream buffer as new writes would just expand the buffer.
330-
// For now, we assume that the current write_end is the end of the buffer. We use this aritifical
330+
// For now, we assume that the current write_end is the end of the buffer. We use this artificial
331331
// end to restrict the read head from seeking beyond what is available.
332332

333333
pos_type end(m_size);

Release/src/http/client/http_win7.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ class winhttp_client : public _http_client_communicator
654654
// Capture the current read position of the stream.
655655
auto rbuf = winhttp_context->_get_readbuffer();
656656

657-
// Record starting position incase request is challenged for authorization
657+
// Record starting position in case request is challenged for authorization
658658
// and needs to seek back to where reading is started from.
659659
winhttp_context->m_startingPosition = rbuf.getpos(std::ios_base::in);
660660

Release/tests/common/TestRunner/test_runner.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,8 @@ bool IsTestIgnored(UnitTest::Test *pTest)
381381
if(pTest->m_properties.Has("Ignore:Windows")) return true;
382382
#elif defined(__APPLE__)
383383
if(pTest->m_properties.Has("Ignore:Apple")) return true;
384+
#elif defined(ANDROID)
385+
if(pTest->m_properties.Has("Ignore:Android")) return true;
384386
#else
385387
if(pTest->m_properties.Has("Ignore:Linux")) return true;
386388
#endif

Release/tests/functional/http/client/request_stream_tests.cpp

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -316,23 +316,26 @@ class test_exception : public std::exception
316316
}
317317
};
318318

319-
// Ignore on WinRT only CodePlex 144
319+
// Ignore on WinRT CodePlex 144
320320
#if !defined(__cplusplus_winrt)
321-
TEST_FIXTURE(uri_address, set_body_stream_exception)
321+
TEST_FIXTURE(uri_address, set_body_stream_exception,
322+
"Ignore:Apple", "296",
323+
"Ignore:Android", "296",
324+
"Ignore:Linux", "296")
322325
{
323-
utility::string_t fname = U("set_body_stream_exception.txt");
324-
fill_file(fname);
325-
326326
test_http_server::scoped_server scoped(m_uri);
327327
scoped.server();
328328
http_client client(m_uri);
329329

330-
auto stream = OPEN_R<uint8_t>(fname).get();
330+
streams::producer_consumer_buffer<uint8_t> buf;
331+
const char *data = "abcdefghijklmnopqrstuvwxyz";
332+
buf.putn(reinterpret_cast<const uint8_t *>(data), 26).wait();
333+
331334
http_request msg(methods::POST);
332-
msg.set_body(stream);
335+
msg.set_body(buf.create_istream());
333336
msg.headers().set_content_length(26);
334337

335-
stream.close(std::ios::in, std::make_exception_ptr(test_exception()));
338+
buf.close(std::ios::in, std::make_exception_ptr(test_exception())).wait();
336339

337340
VERIFY_THROWS(client.request(msg).get(), test_exception);
338341
}
@@ -341,7 +344,10 @@ TEST_FIXTURE(uri_address, set_body_stream_exception)
341344
// These tests aren't possible on WinRT because they don't
342345
// specify a Content-Length.
343346
#if !defined(__cplusplus_winrt)
344-
TEST_FIXTURE(uri_address, stream_close_early)
347+
TEST_FIXTURE(uri_address, stream_close_early,
348+
"Ignore:Apple", "296",
349+
"Ignore:Android", "296",
350+
"Ignore:Linux", "296")
345351
{
346352
http_client client(m_uri);
347353
test_http_server::scoped_server scoped(m_uri);
@@ -358,16 +364,16 @@ TEST_FIXTURE(uri_address, stream_close_early)
358364
unsigned char data[5] = { '1', '2', '3', '4', '5' };
359365
buf.putn(&data[0], 5).wait();
360366

361-
buf.close(std::ios::out);
367+
buf.close(std::ios::out).wait();
362368

363369
// Verify that the task completes successfully
364370
http_asserts::assert_response_equals(responseTask.get(), status_codes::OK);
365371
}
366372

367-
TEST_FIXTURE(uri_address, stream_close_early_with_exception,
368-
"Ignore", "825361",
369-
"Ignore:Linux", "TBD",
370-
"Ignore:Apple", "The test server has trouble closing.")
373+
TEST_FIXTURE(uri_address, stream_close_early_with_exception,
374+
"Ignore:Apple", "296",
375+
"Ignore:Android", "296",
376+
"Ignore:Linux", "296")
371377
{
372378
http_client client(m_uri);
373379
test_http_server::scoped_server scoped(m_uri);
@@ -380,7 +386,7 @@ TEST_FIXTURE(uri_address, stream_close_early)
380386
unsigned char data[5] = { '1', '2', '3', '4', '5' };
381387
buf.putn(&data[0], 5).wait();
382388

383-
buf.close(std::ios::out, std::make_exception_ptr(test_exception()));
389+
buf.close(std::ios::out, std::make_exception_ptr(test_exception())).wait();
384390

385391
// Verify that the responseTask throws the exception set when closing the stream
386392
VERIFY_THROWS(responseTask.get(), test_exception);
@@ -389,10 +395,10 @@ TEST_FIXTURE(uri_address, stream_close_early)
389395

390396
// Ignore on WinRT only CodePlex 144
391397
#if !defined(__cplusplus_winrt)
392-
TEST_FIXTURE(uri_address, stream_close_early_with_exception_and_contentlength,
393-
"Ignore", "825361",
394-
"Ignore:Linux", "TBD",
395-
"Ignore:Apple", "The test server has trouble closing.")
398+
TEST_FIXTURE(uri_address, stream_close_early_with_exception_and_contentlength,
399+
"Ignore:Apple", "296",
400+
"Ignore:Android", "296",
401+
"Ignore:Linux", "296")
396402
{
397403
http_client client(m_uri);
398404
test_http_server::scoped_server scoped(m_uri);
@@ -405,7 +411,7 @@ TEST_FIXTURE(uri_address, stream_close_early_with_exception_and_contentlength,
405411
unsigned char data[5] = { '1', '2', '3', '4', '5' };
406412
buf.putn(&data[0], 5).wait();
407413

408-
buf.close(std::ios::out, std::make_exception_ptr(test_exception()));
414+
buf.close(std::ios::out, std::make_exception_ptr(test_exception())).wait();
409415

410416
// Verify that the responseTask throws the exception set when closing the stream
411417
VERIFY_THROWS(responseTask.get(), test_exception);
@@ -415,9 +421,9 @@ TEST_FIXTURE(uri_address, stream_close_early_with_exception_and_contentlength,
415421
// Ignore on WinRT only CodePlex 144
416422
#if !defined(__cplusplus_winrt)
417423
TEST_FIXTURE(uri_address, stream_close_early_with_contentlength,
418-
"Ignore", "825361",
419-
"Ignore:Linux", "TBD",
420-
"Ignore:Apple", "The test server has trouble closing.")
424+
"Ignore:Apple", "296",
425+
"Ignore:Android", "296",
426+
"Ignore:Linux", "296")
421427
{
422428
http_client client(m_uri);
423429
test_http_server::scoped_server scoped(m_uri);
@@ -430,7 +436,7 @@ TEST_FIXTURE(uri_address, stream_close_early_with_contentlength,
430436
unsigned char data[5] = { '1', '2', '3', '4', '5' };
431437
buf.putn(&data[0], 5).wait();
432438

433-
buf.close(std::ios::out);
439+
buf.close(std::ios::out).wait();
434440

435441
// Verify that the responseTask throws the exception set when closing the stream
436442
VERIFY_THROWS(responseTask.get(), http_exception);

0 commit comments

Comments
 (0)