Commit 3db187091c7e510b651b4e6452a866008a02b4b4
1 parent
a28a1529
feat(iot):【协议改造】优化 coap 单测类的实现
Showing
14 changed files
with
32 additions
and
48 deletions
yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/coap/IotCoapProtocol.java
| @@ -7,14 +7,14 @@ import cn.iocoder.yudao.module.iot.core.util.IotDeviceMessageUtils; | @@ -7,14 +7,14 @@ import cn.iocoder.yudao.module.iot.core.util.IotDeviceMessageUtils; | ||
| 7 | import cn.iocoder.yudao.module.iot.gateway.config.IotGatewayProperties.ProtocolInstanceProperties; | 7 | import cn.iocoder.yudao.module.iot.gateway.config.IotGatewayProperties.ProtocolInstanceProperties; |
| 8 | import cn.iocoder.yudao.module.iot.gateway.protocol.IotProtocol; | 8 | import cn.iocoder.yudao.module.iot.gateway.protocol.IotProtocol; |
| 9 | import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.downstream.IotCoapDownstreamSubscriber; | 9 | import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.downstream.IotCoapDownstreamSubscriber; |
| 10 | -import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem.IotCoapAuthHandler; | ||
| 11 | -import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem.IotCoapAuthResource; | ||
| 12 | -import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem.IotCoapRegisterHandler; | ||
| 13 | -import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem.IotCoapRegisterResource; | ||
| 14 | -import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem.IotCoapRegisterSubHandler; | ||
| 15 | -import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem.IotCoapRegisterSubResource; | ||
| 16 | -import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem.IotCoapUpstreamHandler; | ||
| 17 | -import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem.IotCoapUpstreamTopicResource; | 10 | +import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream.IotCoapAuthHandler; |
| 11 | +import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream.IotCoapAuthResource; | ||
| 12 | +import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream.IotCoapRegisterHandler; | ||
| 13 | +import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream.IotCoapRegisterResource; | ||
| 14 | +import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream.IotCoapRegisterSubHandler; | ||
| 15 | +import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream.IotCoapRegisterSubResource; | ||
| 16 | +import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream.IotCoapUpstreamHandler; | ||
| 17 | +import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream.IotCoapUpstreamTopicResource; | ||
| 18 | import lombok.Getter; | 18 | import lombok.Getter; |
| 19 | import lombok.extern.slf4j.Slf4j; | 19 | import lombok.extern.slf4j.Slf4j; |
| 20 | import org.eclipse.californium.core.CoapResource; | 20 | import org.eclipse.californium.core.CoapResource; |
yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/coap/handler/upstrem/IotCoapAbstractHandler.java renamed to yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/coap/handler/upstream/IotCoapAbstractHandler.java
| 1 | -package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem; | 1 | +package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.hutool.core.util.ArrayUtil; | 4 | import cn.hutool.core.util.ArrayUtil; |
yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/coap/handler/upstrem/IotCoapAuthHandler.java renamed to yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/coap/handler/upstream/IotCoapAuthHandler.java
| 1 | -package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem; | 1 | +package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.lang.Assert; | 3 | import cn.hutool.core.lang.Assert; |
| 4 | import cn.hutool.core.map.MapUtil; | 4 | import cn.hutool.core.map.MapUtil; |
yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/coap/handler/upstrem/IotCoapAuthResource.java renamed to yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/coap/handler/upstream/IotCoapAuthResource.java
| 1 | -package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem; | 1 | +package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream; |
| 2 | 2 | ||
| 3 | import lombok.extern.slf4j.Slf4j; | 3 | import lombok.extern.slf4j.Slf4j; |
| 4 | import org.eclipse.californium.core.CoapResource; | 4 | import org.eclipse.californium.core.CoapResource; |
yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/coap/handler/upstrem/IotCoapRegisterHandler.java renamed to yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/coap/handler/upstream/IotCoapRegisterHandler.java
| 1 | -package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem; | 1 | +package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.lang.Assert; | 3 | import cn.hutool.core.lang.Assert; |
| 4 | import cn.hutool.extra.spring.SpringUtil; | 4 | import cn.hutool.extra.spring.SpringUtil; |
yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/coap/handler/upstrem/IotCoapRegisterResource.java renamed to yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/coap/handler/upstream/IotCoapRegisterResource.java
| 1 | -package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem; | 1 | +package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream; |
| 2 | 2 | ||
| 3 | import lombok.extern.slf4j.Slf4j; | 3 | import lombok.extern.slf4j.Slf4j; |
| 4 | import org.eclipse.californium.core.CoapResource; | 4 | import org.eclipse.californium.core.CoapResource; |
yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/coap/handler/upstrem/IotCoapRegisterSubHandler.java renamed to yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/coap/handler/upstream/IotCoapRegisterSubHandler.java
| 1 | -package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem; | 1 | +package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.hutool.core.lang.Assert; | 4 | import cn.hutool.core.lang.Assert; |
yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/coap/handler/upstrem/IotCoapRegisterSubResource.java renamed to yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/coap/handler/upstream/IotCoapRegisterSubResource.java
| 1 | -package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem; | 1 | +package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream; |
| 2 | 2 | ||
| 3 | import lombok.extern.slf4j.Slf4j; | 3 | import lombok.extern.slf4j.Slf4j; |
| 4 | import org.eclipse.californium.core.CoapResource; | 4 | import org.eclipse.californium.core.CoapResource; |
yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/coap/handler/upstrem/IotCoapUpstreamHandler.java renamed to yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/coap/handler/upstream/IotCoapUpstreamHandler.java
| 1 | -package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem; | 1 | +package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.hutool.core.lang.Assert; | 4 | import cn.hutool.core.lang.Assert; |
yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/coap/handler/upstrem/IotCoapUpstreamTopicResource.java renamed to yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/coap/handler/upstream/IotCoapUpstreamTopicResource.java
| 1 | -package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem; | 1 | +package cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream; |
| 2 | 2 | ||
| 3 | import lombok.extern.slf4j.Slf4j; | 3 | import lombok.extern.slf4j.Slf4j; |
| 4 | import org.eclipse.californium.core.CoapResource; | 4 | import org.eclipse.californium.core.CoapResource; |
yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/coap/util/IotCoapUtils.java deleted
| 1 | -package cn.iocoder.yudao.module.iot.gateway.protocol.coap.util; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstrem.IotCoapAbstractHandler; | ||
| 4 | - | ||
| 5 | -/** | ||
| 6 | - * IoT CoAP 协议工具类 | ||
| 7 | - * | ||
| 8 | - * @author 芋道源码 | ||
| 9 | - */ | ||
| 10 | -public class IotCoapUtils { | ||
| 11 | - | ||
| 12 | - /** | ||
| 13 | - * 自定义 CoAP Option 编号,用于携带 Token | ||
| 14 | - * <p> | ||
| 15 | - * CoAP Option 范围 2048-65535 属于实验/自定义范围 | ||
| 16 | - */ | ||
| 17 | - public static final int OPTION_TOKEN = IotCoapAbstractHandler.OPTION_TOKEN; | ||
| 18 | - | ||
| 19 | -} |
yudao-module-iot/yudao-module-iot-gateway/src/test/java/cn/iocoder/yudao/module/iot/gateway/protocol/coap/IotDirectDeviceCoapProtocolIntegrationTest.java
| @@ -9,7 +9,6 @@ import cn.iocoder.yudao.module.iot.core.topic.auth.IotDeviceRegisterReqDTO; | @@ -9,7 +9,6 @@ import cn.iocoder.yudao.module.iot.core.topic.auth.IotDeviceRegisterReqDTO; | ||
| 9 | import cn.iocoder.yudao.module.iot.core.topic.event.IotDeviceEventPostReqDTO; | 9 | import cn.iocoder.yudao.module.iot.core.topic.event.IotDeviceEventPostReqDTO; |
| 10 | import cn.iocoder.yudao.module.iot.core.topic.property.IotDevicePropertyPostReqDTO; | 10 | import cn.iocoder.yudao.module.iot.core.topic.property.IotDevicePropertyPostReqDTO; |
| 11 | import cn.iocoder.yudao.module.iot.core.util.IotDeviceAuthUtils; | 11 | import cn.iocoder.yudao.module.iot.core.util.IotDeviceAuthUtils; |
| 12 | -import cn.iocoder.yudao.module.iot.gateway.protocol.coap.util.IotCoapUtils; | ||
| 13 | import lombok.extern.slf4j.Slf4j; | 12 | import lombok.extern.slf4j.Slf4j; |
| 14 | import org.eclipse.californium.core.CoapClient; | 13 | import org.eclipse.californium.core.CoapClient; |
| 15 | import org.eclipse.californium.core.CoapResponse; | 14 | import org.eclipse.californium.core.CoapResponse; |
| @@ -23,6 +22,8 @@ import org.junit.jupiter.api.BeforeAll; | @@ -23,6 +22,8 @@ import org.junit.jupiter.api.BeforeAll; | ||
| 23 | import org.junit.jupiter.api.Disabled; | 22 | import org.junit.jupiter.api.Disabled; |
| 24 | import org.junit.jupiter.api.Test; | 23 | import org.junit.jupiter.api.Test; |
| 25 | 24 | ||
| 25 | +import static cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream.IotCoapAbstractHandler.OPTION_TOKEN; | ||
| 26 | + | ||
| 26 | /** | 27 | /** |
| 27 | * IoT 直连设备 CoAP 协议集成测试(手动测试) | 28 | * IoT 直连设备 CoAP 协议集成测试(手动测试) |
| 28 | * | 29 | * |
| @@ -134,7 +135,7 @@ public class IotDirectDeviceCoapProtocolIntegrationTest { | @@ -134,7 +135,7 @@ public class IotDirectDeviceCoapProtocolIntegrationTest { | ||
| 134 | request.setURI(uri); | 135 | request.setURI(uri); |
| 135 | request.setPayload(payload); | 136 | request.setPayload(payload); |
| 136 | request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON); | 137 | request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON); |
| 137 | - request.getOptions().addOption(new Option(IotCoapUtils.OPTION_TOKEN, TOKEN)); | 138 | + request.getOptions().addOption(new Option(OPTION_TOKEN, TOKEN)); |
| 138 | 139 | ||
| 139 | CoapResponse response = client.advanced(request); | 140 | CoapResponse response = client.advanced(request); |
| 140 | // 2.2 输出结果 | 141 | // 2.2 输出结果 |
| @@ -177,7 +178,7 @@ public class IotDirectDeviceCoapProtocolIntegrationTest { | @@ -177,7 +178,7 @@ public class IotDirectDeviceCoapProtocolIntegrationTest { | ||
| 177 | request.setURI(uri); | 178 | request.setURI(uri); |
| 178 | request.setPayload(payload); | 179 | request.setPayload(payload); |
| 179 | request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON); | 180 | request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON); |
| 180 | - request.getOptions().addOption(new Option(IotCoapUtils.OPTION_TOKEN, TOKEN)); | 181 | + request.getOptions().addOption(new Option(OPTION_TOKEN, TOKEN)); |
| 181 | 182 | ||
| 182 | CoapResponse response = client.advanced(request); | 183 | CoapResponse response = client.advanced(request); |
| 183 | // 2.2 输出结果 | 184 | // 2.2 输出结果 |
yudao-module-iot/yudao-module-iot-gateway/src/test/java/cn/iocoder/yudao/module/iot/gateway/protocol/coap/IotGatewayDeviceCoapProtocolIntegrationTest.java
| @@ -13,7 +13,6 @@ import cn.iocoder.yudao.module.iot.core.topic.topo.IotDeviceTopoAddReqDTO; | @@ -13,7 +13,6 @@ import cn.iocoder.yudao.module.iot.core.topic.topo.IotDeviceTopoAddReqDTO; | ||
| 13 | import cn.iocoder.yudao.module.iot.core.topic.topo.IotDeviceTopoDeleteReqDTO; | 13 | import cn.iocoder.yudao.module.iot.core.topic.topo.IotDeviceTopoDeleteReqDTO; |
| 14 | import cn.iocoder.yudao.module.iot.core.topic.topo.IotDeviceTopoGetReqDTO; | 14 | import cn.iocoder.yudao.module.iot.core.topic.topo.IotDeviceTopoGetReqDTO; |
| 15 | import cn.iocoder.yudao.module.iot.core.util.IotDeviceAuthUtils; | 15 | import cn.iocoder.yudao.module.iot.core.util.IotDeviceAuthUtils; |
| 16 | -import cn.iocoder.yudao.module.iot.gateway.protocol.coap.util.IotCoapUtils; | ||
| 17 | import lombok.extern.slf4j.Slf4j; | 16 | import lombok.extern.slf4j.Slf4j; |
| 18 | import org.eclipse.californium.core.CoapClient; | 17 | import org.eclipse.californium.core.CoapClient; |
| 19 | import org.eclipse.californium.core.CoapResponse; | 18 | import org.eclipse.californium.core.CoapResponse; |
| @@ -30,6 +29,8 @@ import org.junit.jupiter.api.Test; | @@ -30,6 +29,8 @@ import org.junit.jupiter.api.Test; | ||
| 30 | import java.util.Collections; | 29 | import java.util.Collections; |
| 31 | import java.util.Map; | 30 | import java.util.Map; |
| 32 | 31 | ||
| 32 | +import static cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream.IotCoapAbstractHandler.OPTION_TOKEN; | ||
| 33 | + | ||
| 33 | /** | 34 | /** |
| 34 | * IoT 网关设备 CoAP 协议集成测试(手动测试) | 35 | * IoT 网关设备 CoAP 协议集成测试(手动测试) |
| 35 | * | 36 | * |
| @@ -158,7 +159,7 @@ public class IotGatewayDeviceCoapProtocolIntegrationTest { | @@ -158,7 +159,7 @@ public class IotGatewayDeviceCoapProtocolIntegrationTest { | ||
| 158 | request.setURI(uri); | 159 | request.setURI(uri); |
| 159 | request.setPayload(payload); | 160 | request.setPayload(payload); |
| 160 | request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON); | 161 | request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON); |
| 161 | - request.getOptions().addOption(new Option(IotCoapUtils.OPTION_TOKEN, GATEWAY_TOKEN)); | 162 | + request.getOptions().addOption(new Option(OPTION_TOKEN, GATEWAY_TOKEN)); |
| 162 | 163 | ||
| 163 | CoapResponse response = client.advanced(request); | 164 | CoapResponse response = client.advanced(request); |
| 164 | // 2.2 输出结果 | 165 | // 2.2 输出结果 |
| @@ -201,7 +202,7 @@ public class IotGatewayDeviceCoapProtocolIntegrationTest { | @@ -201,7 +202,7 @@ public class IotGatewayDeviceCoapProtocolIntegrationTest { | ||
| 201 | request.setURI(uri); | 202 | request.setURI(uri); |
| 202 | request.setPayload(payload); | 203 | request.setPayload(payload); |
| 203 | request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON); | 204 | request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON); |
| 204 | - request.getOptions().addOption(new Option(IotCoapUtils.OPTION_TOKEN, GATEWAY_TOKEN)); | 205 | + request.getOptions().addOption(new Option(OPTION_TOKEN, GATEWAY_TOKEN)); |
| 205 | 206 | ||
| 206 | CoapResponse response = client.advanced(request); | 207 | CoapResponse response = client.advanced(request); |
| 207 | // 2.2 输出结果 | 208 | // 2.2 输出结果 |
| @@ -242,7 +243,7 @@ public class IotGatewayDeviceCoapProtocolIntegrationTest { | @@ -242,7 +243,7 @@ public class IotGatewayDeviceCoapProtocolIntegrationTest { | ||
| 242 | request.setURI(uri); | 243 | request.setURI(uri); |
| 243 | request.setPayload(payload); | 244 | request.setPayload(payload); |
| 244 | request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON); | 245 | request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON); |
| 245 | - request.getOptions().addOption(new Option(IotCoapUtils.OPTION_TOKEN, GATEWAY_TOKEN)); | 246 | + request.getOptions().addOption(new Option(OPTION_TOKEN, GATEWAY_TOKEN)); |
| 246 | 247 | ||
| 247 | CoapResponse response = client.advanced(request); | 248 | CoapResponse response = client.advanced(request); |
| 248 | // 2.2 输出结果 | 249 | // 2.2 输出结果 |
| @@ -289,7 +290,7 @@ public class IotGatewayDeviceCoapProtocolIntegrationTest { | @@ -289,7 +290,7 @@ public class IotGatewayDeviceCoapProtocolIntegrationTest { | ||
| 289 | request.setURI(uri); | 290 | request.setURI(uri); |
| 290 | request.setPayload(payload); | 291 | request.setPayload(payload); |
| 291 | request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON); | 292 | request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON); |
| 292 | - request.getOptions().addOption(new Option(IotCoapUtils.OPTION_TOKEN, GATEWAY_TOKEN)); | 293 | + request.getOptions().addOption(new Option(OPTION_TOKEN, GATEWAY_TOKEN)); |
| 293 | 294 | ||
| 294 | CoapResponse response = client.advanced(request); | 295 | CoapResponse response = client.advanced(request); |
| 295 | // 2.2 输出结果 | 296 | // 2.2 输出结果 |
| @@ -362,7 +363,7 @@ public class IotGatewayDeviceCoapProtocolIntegrationTest { | @@ -362,7 +363,7 @@ public class IotGatewayDeviceCoapProtocolIntegrationTest { | ||
| 362 | request.setURI(uri); | 363 | request.setURI(uri); |
| 363 | request.setPayload(payload); | 364 | request.setPayload(payload); |
| 364 | request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON); | 365 | request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON); |
| 365 | - request.getOptions().addOption(new Option(IotCoapUtils.OPTION_TOKEN, GATEWAY_TOKEN)); | 366 | + request.getOptions().addOption(new Option(OPTION_TOKEN, GATEWAY_TOKEN)); |
| 366 | 367 | ||
| 367 | CoapResponse response = client.advanced(request); | 368 | CoapResponse response = client.advanced(request); |
| 368 | // 2.2 输出结果 | 369 | // 2.2 输出结果 |
yudao-module-iot/yudao-module-iot-gateway/src/test/java/cn/iocoder/yudao/module/iot/gateway/protocol/coap/IotGatewaySubDeviceCoapProtocolIntegrationTest.java
| @@ -8,7 +8,6 @@ import cn.iocoder.yudao.module.iot.core.enums.IotDeviceMessageMethodEnum; | @@ -8,7 +8,6 @@ import cn.iocoder.yudao.module.iot.core.enums.IotDeviceMessageMethodEnum; | ||
| 8 | import cn.iocoder.yudao.module.iot.core.topic.event.IotDeviceEventPostReqDTO; | 8 | import cn.iocoder.yudao.module.iot.core.topic.event.IotDeviceEventPostReqDTO; |
| 9 | import cn.iocoder.yudao.module.iot.core.topic.property.IotDevicePropertyPostReqDTO; | 9 | import cn.iocoder.yudao.module.iot.core.topic.property.IotDevicePropertyPostReqDTO; |
| 10 | import cn.iocoder.yudao.module.iot.core.util.IotDeviceAuthUtils; | 10 | import cn.iocoder.yudao.module.iot.core.util.IotDeviceAuthUtils; |
| 11 | -import cn.iocoder.yudao.module.iot.gateway.protocol.coap.util.IotCoapUtils; | ||
| 12 | import lombok.extern.slf4j.Slf4j; | 11 | import lombok.extern.slf4j.Slf4j; |
| 13 | import org.eclipse.californium.core.CoapClient; | 12 | import org.eclipse.californium.core.CoapClient; |
| 14 | import org.eclipse.californium.core.CoapResponse; | 13 | import org.eclipse.californium.core.CoapResponse; |
| @@ -22,6 +21,8 @@ import org.junit.jupiter.api.BeforeAll; | @@ -22,6 +21,8 @@ import org.junit.jupiter.api.BeforeAll; | ||
| 22 | import org.junit.jupiter.api.Disabled; | 21 | import org.junit.jupiter.api.Disabled; |
| 23 | import org.junit.jupiter.api.Test; | 22 | import org.junit.jupiter.api.Test; |
| 24 | 23 | ||
| 24 | +import static cn.iocoder.yudao.module.iot.gateway.protocol.coap.handler.upstream.IotCoapAbstractHandler.OPTION_TOKEN; | ||
| 25 | + | ||
| 25 | /** | 26 | /** |
| 26 | * IoT 网关子设备 CoAP 协议集成测试(手动测试) | 27 | * IoT 网关子设备 CoAP 协议集成测试(手动测试) |
| 27 | * | 28 | * |
| @@ -137,7 +138,7 @@ public class IotGatewaySubDeviceCoapProtocolIntegrationTest { | @@ -137,7 +138,7 @@ public class IotGatewaySubDeviceCoapProtocolIntegrationTest { | ||
| 137 | request.setURI(uri); | 138 | request.setURI(uri); |
| 138 | request.setPayload(payload); | 139 | request.setPayload(payload); |
| 139 | request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON); | 140 | request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON); |
| 140 | - request.getOptions().addOption(new Option(IotCoapUtils.OPTION_TOKEN, TOKEN)); | 141 | + request.getOptions().addOption(new Option(OPTION_TOKEN, TOKEN)); |
| 141 | 142 | ||
| 142 | CoapResponse response = client.advanced(request); | 143 | CoapResponse response = client.advanced(request); |
| 143 | // 2.2 输出结果 | 144 | // 2.2 输出结果 |
| @@ -185,7 +186,7 @@ public class IotGatewaySubDeviceCoapProtocolIntegrationTest { | @@ -185,7 +186,7 @@ public class IotGatewaySubDeviceCoapProtocolIntegrationTest { | ||
| 185 | request.setURI(uri); | 186 | request.setURI(uri); |
| 186 | request.setPayload(payload); | 187 | request.setPayload(payload); |
| 187 | request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON); | 188 | request.getOptions().setContentFormat(MediaTypeRegistry.APPLICATION_JSON); |
| 188 | - request.getOptions().addOption(new Option(IotCoapUtils.OPTION_TOKEN, TOKEN)); | 189 | + request.getOptions().addOption(new Option(OPTION_TOKEN, TOKEN)); |
| 189 | 190 | ||
| 190 | CoapResponse response = client.advanced(request); | 191 | CoapResponse response = client.advanced(request); |
| 191 | // 2.2 输出结果 | 192 | // 2.2 输出结果 |