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>
public class EncoderEmbedder<E> extends AbstractCodecEmbedder<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 aStringinto a Base64-encodedChannelBufferwithBase64EncoderandStringEncoderwithout setting up theChannelPipelineand 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:
DecoderEmbedder
-
-
Field Summary
-
Fields inherited from class org.jboss.netty.handler.codec.embedder.AbstractCodecEmbedder
productQueue
-
-
Constructor Summary
Constructors Constructor Description EncoderEmbedder(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanoffer(java.lang.Object input)Offers an input object to the pipeline of this embedder.-
Methods inherited from class org.jboss.netty.handler.codec.embedder.AbstractCodecEmbedder
finish, getChannel, getPipeline, isEmpty, peek, poll, pollAll, pollAll, size
-
-
-
-
Constructor Detail
-
EncoderEmbedder
public EncoderEmbedder(ChannelDownstreamHandler... handlers)
Creates a new embedder whose pipeline is composed of the specified handlers.
-
EncoderEmbedder
public EncoderEmbedder(ChannelBufferFactory bufferFactory, ChannelDownstreamHandler... handlers)
Creates a new embedder whose pipeline is composed of the specified handlers.- Parameters:
bufferFactory- theChannelBufferFactoryto be used when creating a new buffer.
-
-
Method Detail
-
offer
public boolean offer(java.lang.Object input)
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())
-
-