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 aString
into a Base64-encodedChannelBuffer
withBase64Encoder
andStringEncoder
without setting up theChannelPipeline
and other mock objects by yourself:String data = "foobar";
EncoderEmbedder
<ChannelBuffer
> embedder = newEncoderEmbedder
<>( newBase64Encoder
(), newStringEncoder
()); embedder.offer(data);ChannelBuffer
encoded = 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 boolean
offer(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
- theChannelBufferFactory
to be used when creating a new buffer.
-
-
Method Detail
-
offer
public boolean offer(java.lang.Object input)
Description copied from interface:CodecEmbedder
Offers an input object to the pipeline of this embedder.- Returns:
true
if and only if there is something to read in the product queue (seeCodecEmbedder.poll()
andCodecEmbedder.peek()
)
-
-