use of org.fisco.bcos.channel.dto.ChannelMessage2 in project web3sdk by FISCO-BCOS.
the class ChannelMessage2Test method channelMessage2CodecTest0.
@Test
public void channelMessage2CodecTest0() {
ChannelMessage2 channelMessage2 = new ChannelMessage2();
String seq = UUID.randomUUID().toString().replaceAll("-", "");
Integer result = Integer.valueOf(0);
String content = "test content";
String topic = "test_topic";
channelMessage2.setSeq(seq);
channelMessage2.setResult(result);
channelMessage2.setType((short) ChannelMessageType.AMOP_REQUEST.getType());
channelMessage2.setData(content.getBytes());
channelMessage2.setTopic(topic);
ByteBuf buffer = Unpooled.buffer();
channelMessage2.writeHeader(buffer);
channelMessage2.writeExtra(buffer);
ChannelMessage2 channelMessage21 = new ChannelMessage2();
channelMessage21.readHeader(buffer);
channelMessage21.readExtra(buffer);
assertEquals(channelMessage21.getTopic(), topic);
assertEquals(new String(channelMessage21.getData()), content);
assertEquals(channelMessage21.getResult(), result);
assertEquals(channelMessage21.getSeq(), seq);
assertEquals(channelMessage21.getType().intValue(), ChannelMessageType.AMOP_REQUEST.getType());
}
Aggregations