This commit is contained in:
2025-09-06 11:58:18 +08:00
commit 8d34972119
1483 changed files with 141190 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
package com.gxwebsoft.config;
import com.gxwebsoft.common.core.config.MqttProperties;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import javax.annotation.Resource;
/**
* MQTT配置属性测试类
*
* @author 科技小王子
* @since 2025-07-02
*/
@SpringBootTest
@ActiveProfiles("dev")
public class MqttPropertiesTest {
@Resource
private MqttProperties mqttProperties;
@Test
public void testMqttPropertiesLoading() {
System.out.println("=== MQTT配置属性测试 ===");
System.out.println("Host: " + mqttProperties.getHost());
System.out.println("Username: " + mqttProperties.getUsername());
System.out.println("Password: " + (mqttProperties.getPassword() != null ? "***" : "null"));
System.out.println("ClientIdPrefix: " + mqttProperties.getClientIdPrefix());
System.out.println("Topic: " + mqttProperties.getTopic());
System.out.println("QoS: " + mqttProperties.getQos());
System.out.println("ConnectionTimeout: " + mqttProperties.getConnectionTimeout());
System.out.println("KeepAliveInterval: " + mqttProperties.getKeepAliveInterval());
System.out.println("AutoReconnect: " + mqttProperties.isAutoReconnect());
System.out.println("CleanSession: " + mqttProperties.isCleanSession());
// 验证关键配置不为空
assert mqttProperties.getHost() != null : "Host不能为空";
assert mqttProperties.getClientIdPrefix() != null : "ClientIdPrefix不能为空";
assert mqttProperties.getTopic() != null : "Topic不能为空";
System.out.println("MQTT配置属性测试通过");
}
}

View File

@@ -0,0 +1,51 @@
package com.gxwebsoft.config;
import com.gxwebsoft.common.core.config.ConfigProperties;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import static org.junit.jupiter.api.Assertions.*;
/**
* 服务器URL配置测试
* 验证server-url配置是否正确从配置文件读取
*/
@SpringBootTest
@ActiveProfiles("dev")
public class ServerUrlConfigTest {
@Autowired
private ConfigProperties configProperties;
@Test
public void testServerUrlConfiguration() {
// 验证配置属性不为空
assertNotNull(configProperties, "ConfigProperties should not be null");
// 验证server-url配置正确读取
String serverUrl = configProperties.getServerUrl();
assertNotNull(serverUrl, "Server URL should not be null");
assertFalse(serverUrl.isEmpty(), "Server URL should not be empty");
// 在开发环境下,应该是本地地址
assertTrue(serverUrl.contains("127.0.0.1") || serverUrl.contains("localhost"),
"In dev environment, server URL should contain localhost or 127.0.0.1");
System.out.println("当前配置的服务器URL: " + serverUrl);
}
@Test
public void testServerUrlFormat() {
String serverUrl = configProperties.getServerUrl();
// 验证URL格式
assertTrue(serverUrl.startsWith("http://") || serverUrl.startsWith("https://"),
"Server URL should start with http:// or https://");
assertTrue(serverUrl.endsWith("/api"),
"Server URL should end with /api");
System.out.println("服务器URL格式验证通过: " + serverUrl);
}
}