Class EncoderEmbedder<E>
java.lang.Object
org.jboss.netty.handler.codec.embedder.AbstractCodecEmbedder<E>
org.jboss.netty.handler.codec.embedder.EncoderEmbedder<E>
- All Implemented Interfaces:
CodecEmbedder<E>
A helper that wraps an encoder so that it can be used without doing actual
I/O in unit tests or higher level codecs. For example, you can encode a
String into a Base64-encoded ChannelBuffer with
Base64Encoder and StringEncoder without setting up the
ChannelPipeline and other mock objects by yourself:
String data = "foobar";EncoderEmbedder<ChannelBuffer> embedder = newEncoderEmbedder<>( newBase64Encoder(), newStringEncoder()); embedder.offer(data);ChannelBufferencoded = embedder.poll(); assert encoded.toString(CharsetUtil.US_ASCII).equals("Zm9vYmFy");
- See Also:
-
Field Summary
Fields inherited from class AbstractCodecEmbedder
productQueue -
Constructor Summary
ConstructorsConstructorDescriptionEncoderEmbedder(ChannelBufferFactory bufferFactory, ChannelDownstreamHandler... handlers) Creates a new embedder whose pipeline is composed of the specified handlers.EncoderEmbedder(ChannelDownstreamHandler... handlers) Creates a new embedder whose pipeline is composed of the specified handlers. -
Method Summary
Methods inherited from class AbstractCodecEmbedder
finish, getChannel, getPipeline, isEmpty, peek, poll, pollAll, pollAll, size
-
Constructor Details
-
EncoderEmbedder
Creates a new embedder whose pipeline is composed of the specified handlers. -
EncoderEmbedder
Creates a new embedder whose pipeline is composed of the specified handlers.- Parameters:
bufferFactory- theChannelBufferFactoryto be used when creating a new buffer.
-
-
Method Details
-
offer
Description copied from interface:CodecEmbedderOffers an input object to the pipeline of this embedder.- Returns:
trueif and only if there is something to read in the product queue (seeCodecEmbedder.poll()andCodecEmbedder.peek())
-