| 66 | |
| 67 | |
| 68 | TEST(RecordIOReaderTest, EndOfFile) |
| 69 | { |
| 70 | // Write some data to the pipe so that records |
| 71 | // are available before any reads occur. |
| 72 | string data; |
| 73 | |
| 74 | data += ::recordio::encode("HELLO"); |
| 75 | data += ::recordio::encode("WORLD!"); |
| 76 | |
| 77 | process::http::Pipe pipe; |
| 78 | pipe.writer().write(data); |
| 79 | |
| 80 | mesos::internal::recordio::Reader<string> reader( |
| 81 | strings::lower, pipe.reader()); |
| 82 | |
| 83 | AWAIT_EXPECT_EQ(Result<string>::some("hello"), reader.read()); |
| 84 | AWAIT_EXPECT_EQ(Result<string>::some("world!"), reader.read()); |
| 85 | |
| 86 | // Have multiple outstanding reads before we close the pipe. |
| 87 | Future<Result<string>> read1 = reader.read(); |
| 88 | Future<Result<string>> read2 = reader.read(); |
| 89 | |
| 90 | EXPECT_TRUE(read1.isPending()); |
| 91 | EXPECT_TRUE(read2.isPending()); |
| 92 | |
| 93 | pipe.writer().write(::recordio::encode("goodbye")); |
| 94 | pipe.writer().close(); |
| 95 | |
| 96 | AWAIT_EXPECT_EQ(Result<string>::some("goodbye"), read1); |
| 97 | AWAIT_EXPECT_EQ(Result<string>::none(), read2); |
| 98 | |
| 99 | // Subsequent reads should return EOF. |
| 100 | AWAIT_EXPECT_EQ(Result<string>::none(), reader.read()); |
| 101 | } |
| 102 | |
| 103 | |
| 104 | TEST(RecordIOReaderTest, DecodingFailure) |