mirror of
https://gitee.com/zhijiantianya/ruoyi-vue-pro.git
synced 2026-03-22 05:07:17 +08:00
feat(iot):【协议改造】优化 coap 单测类的实现
This commit is contained in:
@@ -7,14 +7,14 @@ import cn.iocoder.yudao.module.iot.core.util.IotDeviceMessageUtils;
|
||||
import cn.iocoder.yudao.module.iot.gateway.config.IotGatewayProperties.ProtocolInstanceProperties;
|
||||
import cn.iocoder.yudao.module.iot.gateway.protocol.IotProtocol;
|
||||
import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.downstream.IotCoapDownstreamSubscriber;
|
||||
import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem.IotCoapAuthHandler;
|
||||
import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem.IotCoapAuthResource;
|
||||
import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem.IotCoapRegisterHandler;
|
||||
import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem.IotCoapRegisterResource;
|
||||
import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem.IotCoapRegisterSubHandler;
|
||||
import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem.IotCoapRegisterSubResource;
|
||||
import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem.IotCoapUpstreamHandler;
|
||||
import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem.IotCoapUpstreamTopicResource;
|
||||
import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream.IotCoapAuthHandler;
|
||||
import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream.IotCoapAuthResource;
|
||||
import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream.IotCoapRegisterHandler;
|
||||
import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream.IotCoapRegisterResource;
|
||||
import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream.IotCoapRegisterSubHandler;
|
||||
import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream.IotCoapRegisterSubResource;
|
||||
import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream.IotCoapUpstreamHandler;
|
||||
import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream.IotCoapUpstreamTopicResource;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.californium.core.CoapResource;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem;
|
||||
package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem;
|
||||
package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem;
|
||||
package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.californium.core.CoapResource;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem;
|
||||
package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem;
|
||||
package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.californium.core.CoapResource;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem;
|
||||
package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem;
|
||||
package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.californium.core.CoapResource;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem;
|
||||
package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem;
|
||||
package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.californium.core.CoapResource;
|
||||
@@ -1,19 +0,0 @@
|
||||
package cn.iocoder.yudao.module.iot.gateway.protocol.coap.util;
|
||||
|
||||
import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem.IotCoapAbstractHandler;
|
||||
|
||||
/**
|
||||
* IoT CoAP 协议工具类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public class IotCoapUtils {
|
||||
|
||||
/**
|
||||
* 自定义 CoAP Option 编号,用于携带 Token
|
||||
* <p>
|
||||
* CoAP Option 范围 2048-65535 属于实验/自定义范围
|
||||
*/
|
||||
public static final int OPTION_TOKEN = IotCoapAbstractHandler.OPTION_TOKEN;
|
||||
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import cn.iocoder.yudao.module.iot.core.topic.auth.IotDeviceRegisterReqDTO;
|
||||
import cn.iocoder.yudao.module.iot.core.topic.event.IotDeviceEventPostReqDTO;
|
||||
import cn.iocoder.yudao.module.iot.core.topic.property.IotDevicePropertyPostReqDTO;
|
||||
import cn.iocoder.yudao.module.iot.core.util.IotDeviceAuthUtils;
|
||||
import cn.iocoder.yudao.module.iot.gateway.protocol.coap.util.IotCoapUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.californium.core.CoapClient;
|
||||
import org.eclipse.californium.core.CoapResponse;
|
||||
@@ -23,6 +22,8 @@ import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream.IotCoapAbstractHandler.OPTION_TOKEN;
|
||||
|
||||
/**
|
||||
* IoT 直连设备 CoAP 协议集成测试(手动测试)
|
||||
*
|
||||
@@ -134,7 +135,7 @@ public class IotDirectDeviceCoapProtocolIntegrationTest {
|
||||
request.setURI(uri);
|
||||
request.setPayload(payload);
|
||||
request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON);
|
||||
request.getOptions().addOption(new Option(IotCoapUtils.OPTION_TOKEN, TOKEN));
|
||||
request.getOptions().addOption(new Option(OPTION_TOKEN, TOKEN));
|
||||
|
||||
CoapResponse response = client.advanced(request);
|
||||
// 2.2 输出结果
|
||||
@@ -177,7 +178,7 @@ public class IotDirectDeviceCoapProtocolIntegrationTest {
|
||||
request.setURI(uri);
|
||||
request.setPayload(payload);
|
||||
request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON);
|
||||
request.getOptions().addOption(new Option(IotCoapUtils.OPTION_TOKEN, TOKEN));
|
||||
request.getOptions().addOption(new Option(OPTION_TOKEN, TOKEN));
|
||||
|
||||
CoapResponse response = client.advanced(request);
|
||||
// 2.2 输出结果
|
||||
|
||||
@@ -13,7 +13,6 @@ import cn.iocoder.yudao.module.iot.core.topic.topo.IotDeviceTopoAddReqDTO;
|
||||
import cn.iocoder.yudao.module.iot.core.topic.topo.IotDeviceTopoDeleteReqDTO;
|
||||
import cn.iocoder.yudao.module.iot.core.topic.topo.IotDeviceTopoGetReqDTO;
|
||||
import cn.iocoder.yudao.module.iot.core.util.IotDeviceAuthUtils;
|
||||
import cn.iocoder.yudao.module.iot.gateway.protocol.coap.util.IotCoapUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.californium.core.CoapClient;
|
||||
import org.eclipse.californium.core.CoapResponse;
|
||||
@@ -30,6 +29,8 @@ import org.junit.jupiter.api.Test;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream.IotCoapAbstractHandler.OPTION_TOKEN;
|
||||
|
||||
/**
|
||||
* IoT 网关设备 CoAP 协议集成测试(手动测试)
|
||||
*
|
||||
@@ -158,7 +159,7 @@ public class IotGatewayDeviceCoapProtocolIntegrationTest {
|
||||
request.setURI(uri);
|
||||
request.setPayload(payload);
|
||||
request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON);
|
||||
request.getOptions().addOption(new Option(IotCoapUtils.OPTION_TOKEN, GATEWAY_TOKEN));
|
||||
request.getOptions().addOption(new Option(OPTION_TOKEN, GATEWAY_TOKEN));
|
||||
|
||||
CoapResponse response = client.advanced(request);
|
||||
// 2.2 输出结果
|
||||
@@ -201,7 +202,7 @@ public class IotGatewayDeviceCoapProtocolIntegrationTest {
|
||||
request.setURI(uri);
|
||||
request.setPayload(payload);
|
||||
request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON);
|
||||
request.getOptions().addOption(new Option(IotCoapUtils.OPTION_TOKEN, GATEWAY_TOKEN));
|
||||
request.getOptions().addOption(new Option(OPTION_TOKEN, GATEWAY_TOKEN));
|
||||
|
||||
CoapResponse response = client.advanced(request);
|
||||
// 2.2 输出结果
|
||||
@@ -242,7 +243,7 @@ public class IotGatewayDeviceCoapProtocolIntegrationTest {
|
||||
request.setURI(uri);
|
||||
request.setPayload(payload);
|
||||
request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON);
|
||||
request.getOptions().addOption(new Option(IotCoapUtils.OPTION_TOKEN, GATEWAY_TOKEN));
|
||||
request.getOptions().addOption(new Option(OPTION_TOKEN, GATEWAY_TOKEN));
|
||||
|
||||
CoapResponse response = client.advanced(request);
|
||||
// 2.2 输出结果
|
||||
@@ -289,7 +290,7 @@ public class IotGatewayDeviceCoapProtocolIntegrationTest {
|
||||
request.setURI(uri);
|
||||
request.setPayload(payload);
|
||||
request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON);
|
||||
request.getOptions().addOption(new Option(IotCoapUtils.OPTION_TOKEN, GATEWAY_TOKEN));
|
||||
request.getOptions().addOption(new Option(OPTION_TOKEN, GATEWAY_TOKEN));
|
||||
|
||||
CoapResponse response = client.advanced(request);
|
||||
// 2.2 输出结果
|
||||
@@ -362,7 +363,7 @@ public class IotGatewayDeviceCoapProtocolIntegrationTest {
|
||||
request.setURI(uri);
|
||||
request.setPayload(payload);
|
||||
request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON);
|
||||
request.getOptions().addOption(new Option(IotCoapUtils.OPTION_TOKEN, GATEWAY_TOKEN));
|
||||
request.getOptions().addOption(new Option(OPTION_TOKEN, GATEWAY_TOKEN));
|
||||
|
||||
CoapResponse response = client.advanced(request);
|
||||
// 2.2 输出结果
|
||||
|
||||
@@ -8,7 +8,6 @@ import cn.iocoder.yudao.module.iot.core.enums.IotDeviceMessageMethodEnum;
|
||||
import cn.iocoder.yudao.module.iot.core.topic.event.IotDeviceEventPostReqDTO;
|
||||
import cn.iocoder.yudao.module.iot.core.topic.property.IotDevicePropertyPostReqDTO;
|
||||
import cn.iocoder.yudao.module.iot.core.util.IotDeviceAuthUtils;
|
||||
import cn.iocoder.yudao.module.iot.gateway.protocol.coap.util.IotCoapUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.californium.core.CoapClient;
|
||||
import org.eclipse.californium.core.CoapResponse;
|
||||
@@ -22,6 +21,8 @@ import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream.IotCoapAbstractHandler.OPTION_TOKEN;
|
||||
|
||||
/**
|
||||
* IoT 网关子设备 CoAP 协议集成测试(手动测试)
|
||||
*
|
||||
@@ -137,7 +138,7 @@ public class IotGatewaySubDeviceCoapProtocolIntegrationTest {
|
||||
request.setURI(uri);
|
||||
request.setPayload(payload);
|
||||
request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON);
|
||||
request.getOptions().addOption(new Option(IotCoapUtils.OPTION_TOKEN, TOKEN));
|
||||
request.getOptions().addOption(new Option(OPTION_TOKEN, TOKEN));
|
||||
|
||||
CoapResponse response = client.advanced(request);
|
||||
// 2.2 输出结果
|
||||
@@ -185,7 +186,7 @@ public class IotGatewaySubDeviceCoapProtocolIntegrationTest {
|
||||
request.setURI(uri);
|
||||
request.setPayload(payload);
|
||||
request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON);
|
||||
request.getOptions().addOption(new Option(IotCoapUtils.OPTION_TOKEN, TOKEN));
|
||||
request.getOptions().addOption(new Option(OPTION_TOKEN, TOKEN));
|
||||
|
||||
CoapResponse response = client.advanced(request);
|
||||
// 2.2 输出结果
|
||||
|
||||
Reference in New Issue
Block a user