Protocols::Http::Testing::DataSerializerTest Class Reference

Inherits TestFixture.

Inheritance diagram for Protocols::Http::Testing::DataSerializerTest:

Inheritance graph
[legend]
Collaboration diagram for Protocols::Http::Testing::DataSerializerTest:

Collaboration graph
[legend]
List of all members.

Detailed Description

Tests for DataSerializer.

Thoughts: NO Transfer-Encoding: header -> IdentityCodec Transfer-Encoding; chunked -> ChunkCodec Transfer-Encoding: deflate -> DeflateCodec Transfer-Encoding: deflate chunked -> CodecChain: ChunkCodec | DeflateCodec

if Transfer-Encoding: is not identity??/not specified => Content-Length: MUST be ignored setup decoding chain else if Content-Length is specified => content-length == transfer-length == entity-length use a single IdentityCodec (content-length) else use a single IdentityCodec (-1)?? i.e. read all available

2.If a Transfer-Encoding header field (section 14.41) is present and has any value other than "identity", then the transfer-length is defined by use of the "chunked" transfer-coding (section 3.6), unless the message is terminated by closing the connection.

multipart messages => use MultipartCodec???

In general, HTTP treats a multipart message-body no differently than any other media type: strictly as payload. The one exception is the "multipart/byteranges" type (appendix 19.2) when it appears in a 206 (Partial Content) response, which will be interpreted by some HTTP caching mechanisms as described in sections 13.5.4 and 14.16. In all other cases, an HTTP user agent SHOULD follow the same or similar behavior as a MIME user agent would upon receipt of a multipart type.

HttpClientSession ?? Content-Type: multipart/byteranges HttpClientSession ?? Content-Range:

NO Content-Length: and HTTP/1.1 => a. require Transfer-Encoding: chunked ... b. Connection: close => c. Connection: keep-alive or HTTP/1.1 => ii.

Definition at line 73 of file DataSerializerTest.cpp.

Public Member Functions

void setUp ()
void tearDown ()
void refReadHeaderFails ()
 Reading fails if a complete header cannot be read from transport.
void refReadHeaderOK (const Header &header)
 Read a complete header from transport and create readCodec.
void refReadLfTerminatedHeaderOK (const Header &header)
 Read a complete <LF><LF> terminated header.
void refReadBodyChunk (const Data &chunk)
 A body chunk is read from transport through readCodec.
void refReadBodyChunkFails ()
 The codec cannot read enought data from transport.
void refReadBodyEnd ()
 Reading BodyEnd indicates the end of the body and readCodec is freed.
void stateReadingHeader ()
void stateReadingBody (const Header &header)
void postStateReadingHeader ()
void postStateReadingBody ()
void scenarioReadHeaderFails ()
 We cannot read a header from transport now but we can retry later.
void scenarioReadHeaderOK (const Header &header, bool lfTerminated=false)
 After header is successfully read, we can go on and read the body.
void scenarioReadBody (const Header &header, const QList< Data > &bodyChunks)
 Read a body consisting of a number of chunks followed by BodyEnd().
void testReadHeaderFails ()
void testReadHeader ()
void testReadHeaderLfLfTerminated ()
void testReadBodyOfOneChunk ()
void testReadTwoMessages ()
void testReadMessageWithInterrupts ()
void refWriteHeaderSucceeds (const Header &header)
 After header is written, a writeCodec for the body is created.
void refWriteHeaderFails (const Header &header)
 Writing header fails, no writeCodec for the body is created.
void refWriteBodyChunk (const Data &chunk, bool willSucceed)
 A body chunk is written to transport through writeCodec.
void stateWritingHeader ()
void stateWritingBody (const Header &header)
void postStateWritingHeader ()
void postStateWritingBody ()
void scenarioWriteHeaderFails (const Header &header)
 Writing header to serializer fails.
void scenarioWriteHeaderOK (const Header &header)
 Write header to serializer.
void scenarioWriteBody (const Header &header, const QList< Data > &chunks)
 Write a number of body chunks after a header has already been written.
void testWriteHeaderFails ()
void testWriteHeaderOK ()
void testWriteBodyOfOneChunk ()
void testWriteBodyOfMultipleChunksWithDelays ()
void writeTwoMessages ()

Private Member Functions

 CPPUNIT_TEST_SUITE (DataSerializerTest)
 CPPUNIT_TEST (testReadHeaderFails)
 CPPUNIT_TEST (testReadHeader)
 CPPUNIT_TEST (testReadHeaderLfLfTerminated)
 CPPUNIT_TEST (testReadBodyOfOneChunk)
 CPPUNIT_TEST (testReadTwoMessages)
 CPPUNIT_TEST (testReadMessageWithInterrupts)
 CPPUNIT_TEST (testWriteHeaderFails)
 CPPUNIT_TEST (testWriteHeaderOK)
 CPPUNIT_TEST (testWriteBodyOfOneChunk)
 CPPUNIT_TEST (testWriteBodyOfMultipleChunksWithDelays)
 CPPUNIT_TEST (writeTwoMessages)
 CPPUNIT_TEST_SUITE_END ()

Private Attributes

auto_ptr< TransportMock > transport
auto_ptr< ProtocolMock > protocol
auto_ptr< BodyReaderMock > bodyReader
auto_ptr< BodyWriterMock > bodyWriter
auto_ptr< DataSerializerserializerReal
auto_ptr< DataSerializerDriver > serializer
HeaderBase header
BodyEnd bodyEnd
QList< Datachunks


Member Function Documentation

Protocols::Http::Testing::DataSerializerTest::CPPUNIT_TEST writeTwoMessages   )  [private]
 

Protocols::Http::Testing::DataSerializerTest::CPPUNIT_TEST testWriteBodyOfMultipleChunksWithDelays   )  [private]
 

Protocols::Http::Testing::DataSerializerTest::CPPUNIT_TEST testWriteBodyOfOneChunk   )  [private]
 

Protocols::Http::Testing::DataSerializerTest::CPPUNIT_TEST testWriteHeaderOK   )  [private]
 

Protocols::Http::Testing::DataSerializerTest::CPPUNIT_TEST testWriteHeaderFails   )  [private]
 

Protocols::Http::Testing::DataSerializerTest::CPPUNIT_TEST testReadMessageWithInterrupts   )  [private]
 

Protocols::Http::Testing::DataSerializerTest::CPPUNIT_TEST testReadTwoMessages   )  [private]
 

Protocols::Http::Testing::DataSerializerTest::CPPUNIT_TEST testReadBodyOfOneChunk   )  [private]
 

Protocols::Http::Testing::DataSerializerTest::CPPUNIT_TEST testReadHeaderLfLfTerminated   )  [private]
 

Protocols::Http::Testing::DataSerializerTest::CPPUNIT_TEST testReadHeader   )  [private]
 

Protocols::Http::Testing::DataSerializerTest::CPPUNIT_TEST testReadHeaderFails   )  [private]
 

Protocols::Http::Testing::DataSerializerTest::CPPUNIT_TEST_SUITE DataSerializerTest   )  [private]
 

Protocols::Http::Testing::DataSerializerTest::CPPUNIT_TEST_SUITE_END  )  [private]
 

void Protocols::Http::Testing::DataSerializerTest::postStateReadingBody  )  [inline]
 

Definition at line 235 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::postStateReadingHeader  )  [inline]
 

Definition at line 230 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::postStateWritingBody  )  [inline]
 

Definition at line 355 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::postStateWritingHeader  )  [inline]
 

Definition at line 350 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::refReadBodyChunk const Data chunk  )  [inline]
 

A body chunk is read from transport through readCodec.

Definition at line 183 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::refReadBodyChunkFails  )  [inline]
 

The codec cannot read enought data from transport.

Definition at line 195 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::refReadBodyEnd  )  [inline]
 

Reading BodyEnd indicates the end of the body and readCodec is freed.

Definition at line 207 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::refReadHeaderFails  )  [inline]
 

Reading fails if a complete header cannot be read from transport.

First serializer tries to read a <CR><LF><CR><LF> terminated header. If that does not work, it tries to read a <LF><LF> terminated header which also fails.

Definition at line 134 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::refReadHeaderOK const Header header  )  [inline]
 

Read a complete header from transport and create readCodec.

Definition at line 148 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::refReadLfTerminatedHeaderOK const Header header  )  [inline]
 

Read a complete <LF><LF> terminated header.

Definition at line 164 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::refWriteBodyChunk const Data chunk,
bool  willSucceed
[inline]
 

A body chunk is written to transport through writeCodec.

Definition at line 332 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::refWriteHeaderFails const Header header  )  [inline]
 

Writing header fails, no writeCodec for the body is created.

Definition at line 323 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::refWriteHeaderSucceeds const Header header  )  [inline]
 

After header is written, a writeCodec for the body is created.

Definition at line 312 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::scenarioReadBody const Header header,
const QList< Data > &  bodyChunks
[inline]
 

Read a body consisting of a number of chunks followed by BodyEnd().

Definition at line 260 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::scenarioReadHeaderFails  )  [inline]
 

We cannot read a header from transport now but we can retry later.

Definition at line 241 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::scenarioReadHeaderOK const Header header,
bool  lfTerminated = false
[inline]
 

After header is successfully read, we can go on and read the body.

Definition at line 249 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::scenarioWriteBody const Header header,
const QList< Data > &  chunks
[inline]
 

Write a number of body chunks after a header has already been written.

Parameters:
header is the Header object to use for setting up the pre-state.
chunks is the list of Data objects to write.
All chunks are written to serializer. To make sure every chunk can both fail and succeed, we always test both.

The serializer stops writing the body when a BodyEnd object is received. Afterwards serializer will expect a Header object again.

Definition at line 397 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::scenarioWriteHeaderFails const Header header  )  [inline]
 

Writing header to serializer fails.

Parameters:
header is the header to try to write to serializer.
If header cannot be written, it should be retried later.

Definition at line 366 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::scenarioWriteHeaderOK const Header header  )  [inline]
 

Write header to serializer.

Parameters:
header is the Header which serializer correctly writes.
After header is written successfully, body chunks can be written.

Definition at line 379 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::setUp  )  [inline]
 

Definition at line 101 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::stateReadingBody const Header header  )  [inline]
 

Definition at line 225 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::stateReadingHeader  )  [inline]
 

Definition at line 220 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::stateWritingBody const Header header  )  [inline]
 

Definition at line 345 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::stateWritingHeader  )  [inline]
 

Definition at line 340 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::tearDown  )  [inline]
 

Definition at line 118 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::testReadBodyOfOneChunk  )  [inline]
 

Definition at line 291 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::testReadHeader  )  [inline]
 

Definition at line 281 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::testReadHeaderFails  )  [inline]
 

Definition at line 276 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::testReadHeaderLfLfTerminated  )  [inline]
 

Definition at line 286 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::testReadMessageWithInterrupts  )  [inline]
 

Definition at line 303 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::testReadTwoMessages  )  [inline]
 

Definition at line 297 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::testWriteBodyOfMultipleChunksWithDelays  )  [inline]
 

Definition at line 432 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::testWriteBodyOfOneChunk  )  [inline]
 

Definition at line 426 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::testWriteHeaderFails  )  [inline]
 

Definition at line 416 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::testWriteHeaderOK  )  [inline]
 

Definition at line 421 of file DataSerializerTest.cpp.

void Protocols::Http::Testing::DataSerializerTest::writeTwoMessages  )  [inline]
 

Definition at line 440 of file DataSerializerTest.cpp.


Member Data Documentation

BodyEnd Protocols::Http::Testing::DataSerializerTest::bodyEnd [private]
 

Definition at line 97 of file DataSerializerTest.cpp.

auto_ptr<BodyReaderMock> Protocols::Http::Testing::DataSerializerTest::bodyReader [private]
 

Definition at line 91 of file DataSerializerTest.cpp.

auto_ptr<BodyWriterMock> Protocols::Http::Testing::DataSerializerTest::bodyWriter [private]
 

Definition at line 92 of file DataSerializerTest.cpp.

QList<Data> Protocols::Http::Testing::DataSerializerTest::chunks [private]
 

Definition at line 98 of file DataSerializerTest.cpp.

HeaderBase Protocols::Http::Testing::DataSerializerTest::header [private]
 

Definition at line 96 of file DataSerializerTest.cpp.

auto_ptr<ProtocolMock> Protocols::Http::Testing::DataSerializerTest::protocol [private]
 

Definition at line 90 of file DataSerializerTest.cpp.

auto_ptr<DataSerializerDriver> Protocols::Http::Testing::DataSerializerTest::serializer [private]
 

Definition at line 94 of file DataSerializerTest.cpp.

auto_ptr<DataSerializer> Protocols::Http::Testing::DataSerializerTest::serializerReal [private]
 

Definition at line 93 of file DataSerializerTest.cpp.

auto_ptr<TransportMock> Protocols::Http::Testing::DataSerializerTest::transport [private]
 

Definition at line 89 of file DataSerializerTest.cpp.


The documentation for this class was generated from the following file: