6 Commits

Author SHA1 Message Date
Liam
f8be8ea534 Change to units tests for LengthFieldPrepender class to raise exceptions when errors are thrown.
Motivation:
To ensure that failing tests flag more accurately.

Modifications:
Added AssetNoThrow around calls in tests that can throw.

Result:
Tests flag more accurately and at the source of the problem.
2018-12-13 19:49:35 +00:00
Liam
343428c4e0 Change to units tests for LengthFieldPrepender class to make it work with utf8 strings.
Motivation:
To ensure that non ascii strings work in the test.

Modifications:
One more change to standardDataStringCount forgotten in the last commit.

Result:
Non ascii strings work.
2018-12-10 20:15:01 +00:00
Liam
de879a2dc2 Reuses same buffer for “LengthFIeldPrepender” to prevent multiple allocations.
Removed unnecessary tests and improved test safety across platforms.

Motivation:
To reduce buffer allocations and neaten tests.

Modifications:
Moved the length buffer in the length field prepender to be a member variable.
Ensured that string counts in the tests use utf8 format.
Removed unnecessary tests related to testing bytes remaining in buffers.

Result:
Less buffer allocations.
Neater, more accurate tests.
2018-12-10 19:44:03 +00:00
Liam
88ad78a4b1 Improves the efficiency of the LengthFieldPrepender class by writing directly to the context buffer.
Motivation:
To improve the efficiency of the class.

Modifications:
Now inherits from ChannelOutboundHandler rather than MessageToByteEncoder.
Writes directly to the context buffer.
Corrects an error where one of the public type-aliases was incorrectly set.
Updates unit tests to account for multiple context buffer writes.

Result:
Removes unnecessary buffer writes.
2018-12-05 20:59:20 +00:00
Liam
767f44d28e Ensures that the LengthFieldPrepender class reports a sensible error if the message is too long for the header.
Motivation:
To enhance error reporting.

Modifications:
Added a LengthFieldPrependerError which has a messageDataTooLongForLengthField that is thrown if the length is too long.
An additional test to check that the error is thrown.
Some neatening of comments.

Result:
A clear error will be returned is the length is too long for the header.
2018-12-03 20:30:04 +00:00
Liam
c6eae19fc7 Adds a LengthFieldPrepender class to prepend the length onto a message.
This class is a type of byte to message encoder.

Motivation:
To encode a prepended length field on data so that messages of arbitrary size can be sent.
Can work as a pair with the ‘LengthFieldBasedFrameDecoder’.

Modifications:
Added ‘LengthFieldPrepender’
Added unit tests for ‘LengthFieldPrepender’ in ‘LengthFieldPrependerTest’
Updated the linux text files by running the script.

Result:
The length can now be easily prepended to any message.
2018-11-30 11:59:26 +00:00