Search in sources :

Example 1 with StringStreamEventDecoder

use of co.cask.cdap.data.stream.decoder.StringStreamEventDecoder in project cdap by caskdata.

the class StreamInputFormatTest method testStringStreamEventDecoder.

@Test
public void testStringStreamEventDecoder() {
    String body = "Testing";
    StreamEvent event = new StreamEvent(ImmutableMap.<String, String>of(), Charsets.UTF_8.encode(body));
    StreamEventDecoder<LongWritable, String> decoder = new StringStreamEventDecoder();
    StreamEventDecoder.DecodeResult<LongWritable, String> result = new StreamEventDecoder.DecodeResult<>();
    result = decoder.decode(event, result);
    Assert.assertEquals(event.getTimestamp(), result.getKey().get());
    Assert.assertEquals(body, result.getValue());
}
Also used : IdentityStreamEventDecoder(co.cask.cdap.data.stream.decoder.IdentityStreamEventDecoder) StringStreamEventDecoder(co.cask.cdap.data.stream.decoder.StringStreamEventDecoder) StreamEventDecoder(co.cask.cdap.api.stream.StreamEventDecoder) BytesStreamEventDecoder(co.cask.cdap.data.stream.decoder.BytesStreamEventDecoder) TextStreamEventDecoder(co.cask.cdap.data.stream.decoder.TextStreamEventDecoder) StreamEvent(co.cask.cdap.api.flow.flowlet.StreamEvent) LongWritable(org.apache.hadoop.io.LongWritable) StringStreamEventDecoder(co.cask.cdap.data.stream.decoder.StringStreamEventDecoder) Test(org.junit.Test)

Aggregations

StreamEvent (co.cask.cdap.api.flow.flowlet.StreamEvent)1 StreamEventDecoder (co.cask.cdap.api.stream.StreamEventDecoder)1 BytesStreamEventDecoder (co.cask.cdap.data.stream.decoder.BytesStreamEventDecoder)1 IdentityStreamEventDecoder (co.cask.cdap.data.stream.decoder.IdentityStreamEventDecoder)1 StringStreamEventDecoder (co.cask.cdap.data.stream.decoder.StringStreamEventDecoder)1 TextStreamEventDecoder (co.cask.cdap.data.stream.decoder.TextStreamEventDecoder)1 LongWritable (org.apache.hadoop.io.LongWritable)1 Test (org.junit.Test)1