use of org.apache.rocketmq.iot.common.data.Message in project rocketmq-externals by apache.
the class MqttIdleHandlerTest method test.
@Test
public void test() throws Exception {
Message message = new Message();
idleHandler.channelActive(ctx);
idleHandler.channelRead(ctx, message);
idleHandler.channelReadComplete(ctx);
// sleep for 2s
Thread.sleep(2000);
Mockito.verify(ctx).fireUserEventTriggered(Mockito.any(IdleStateEvent.class));
}
use of org.apache.rocketmq.iot.common.data.Message in project rocketmq-externals by apache.
the class MqttPingreqMessageHandlerTest method testHandleMessage.
@Test
public void testHandleMessage() {
Message message = new Message();
message.setClient(client);
message.setPayload(getMqttPingreqMessage());
handler.handleMessage(message);
Mockito.verify(ctx).writeAndFlush(Mockito.any(MqttMessage.class));
}
use of org.apache.rocketmq.iot.common.data.Message in project rocketmq-externals by apache.
the class MessageDispatcher method channelRead0.
@Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
if (!(msg instanceof MqttMessage)) {
return;
}
Client client = clientManager.get(ctx.channel());
if (client == null) {
client = new MqttClient();
client.setCtx(ctx);
clientManager.put(ctx.channel(), client);
}
MqttMessage mqttMessage = (MqttMessage) msg;
Message message = MessageUtil.getMessage(mqttMessage);
message.setClient(client);
dispatch(message);
}
use of org.apache.rocketmq.iot.common.data.Message in project rocketmq-externals by apache.
the class MqttDispatcherTest method testChanelRead0.
public void testChanelRead0() {
messageDispatcher.registerHandler(Message.Type.MQTT_CONNECT, mockedConnectMessageHandler);
MqttConnectMessage mockedConnectMessage = Mockito.mock(MqttConnectMessage.class);
Message mockedMessage = Mockito.spy(new Message());
Mockito.when(MessageUtil.getMessage(mockedConnectMessage)).thenReturn(mockedMessage);
EmbeddedChannel embeddedChannel = new EmbeddedChannel(messageDispatcher);
embeddedChannel.writeInbound(mockedConnectMessage);
Mockito.verify(mockedConnectMessageHandler).handleMessage(mockedMessage);
}
use of org.apache.rocketmq.iot.common.data.Message in project rocketmq-externals by apache.
the class AbstractMqttMessageHandlerTest method initMessage.
private void initMessage() {
message = new Message();
setupMessage();
message.setClient(client);
}
Aggregations