use of io.scalecube.streams.StreamMessage in project scalecube by scalecube.
the class ByteBufCodecTest method testParseInsignificantSymbols.
@Test
public void testParseInsignificantSymbols() {
List<String> get = ImmutableList.of("subject");
List<String> match = Collections.emptyList();
ByteBufCodec.decode(copiedBuffer("{\n\r\t \"subject\"\n\r\t :\n\r\t \"cool\"\n\r\t }", UTF_8), get, match, consumer);
StreamMessage message = messageBuilder.build();
assertEquals("Whitespaces before and after colon should be ignored", "cool", message.subject());
}
use of io.scalecube.streams.StreamMessage in project scalecube by scalecube.
the class StreamMessageCodecTest method testCodecWithEmptyData.
@Test
public void testCodecWithEmptyData() {
StreamMessage src = StreamMessage.builder().qualifier("q").subject("subject").data(Unpooled.EMPTY_BUFFER).build();
assertEquals("{\"q\":\"q\",\"subject\":\"subject\"}", StreamMessageCodec.encode(src).toString(UTF_8));
}
use of io.scalecube.streams.StreamMessage in project scalecube by scalecube.
the class StreamMessageCodecTest method testCodecWithOnlyQualifierAndData.
@Test
public void testCodecWithOnlyQualifierAndData() {
ByteBuf dataBuf = copiedBuffer("{\"sessiontimerallowed\":1,\"losslimitallowed\":1}", UTF_8);
StreamMessage src = StreamMessage.builder().qualifier("q").data(dataBuf).build();
assertEquals("{\"q\":\"q\",\"data\":{\"sessiontimerallowed\":1,\"losslimitallowed\":1}}", StreamMessageCodec.encode(src).toString(UTF_8));
}
use of io.scalecube.streams.StreamMessage in project scalecube by scalecube.
the class StreamMessageCodecTest method testCodecWithOnlyQualifier.
@Test
public void testCodecWithOnlyQualifier() {
StreamMessage src = StreamMessage.builder().qualifier("q").build();
ByteBuf buf = StreamMessageCodec.encode(src);
assertEquals("{\"q\":\"q\"}", buf.toString(UTF_8));
}
use of io.scalecube.streams.StreamMessage in project scalecube by scalecube.
the class StreamMessageCodecTest method testCodecWithAllFieldsAndNullData.
@Test
public void testCodecWithAllFieldsAndNullData() {
StreamMessage src = StreamMessage.builder().qualifier("q").subject("id0/id1/id2").data(null).build();
assertEquals("{\"q\":\"q\",\"subject\":\"id0/id1/id2\"}", StreamMessageCodec.encode(src).toString(UTF_8));
}
Aggregations