Search in sources :

Example 11 with StreamMessage

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());
}
Also used : StreamMessage(io.scalecube.streams.StreamMessage) Test(org.junit.Test)

Example 12 with StreamMessage

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));
}
Also used : StreamMessage(io.scalecube.streams.StreamMessage) Test(org.junit.Test)

Example 13 with StreamMessage

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));
}
Also used : StreamMessage(io.scalecube.streams.StreamMessage) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 14 with StreamMessage

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));
}
Also used : StreamMessage(io.scalecube.streams.StreamMessage) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 15 with StreamMessage

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));
}
Also used : StreamMessage(io.scalecube.streams.StreamMessage) Test(org.junit.Test)

Aggregations

StreamMessage (io.scalecube.streams.StreamMessage)21 Test (org.junit.Test)21 ByteBuf (io.netty.buffer.ByteBuf)11