yeg
6 天以前 e38aca8134570513435c003c25dc05f1ae51c9c9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.battery.business.runtime;
 
import static org.junit.jupiter.api.Assertions.assertEquals;
 
import java.util.List;
import org.junit.jupiter.api.Test;
import org.springframework.boot.env.YamlPropertySourceLoader;
import org.springframework.core.io.ClassPathResource;
 
/**
 * 默认启动不连接任何设备:没有配置来源时装配无设备实现,真实来源按适配器实例逐行配置。
 * 这里锁定配置文件里的默认 profile,避免有人在配置里提前打开设备连接。
 */
class DefaultSpringProfileContractTest
{
    @Test
    void usesNoDeviceProfileByDefault() throws Exception
    {
        var sources = new YamlPropertySourceLoader().load("application", new ClassPathResource("application.yml"));
        Object profiles = sources.get(0).getProperty("spring.profiles.active");
 
        assertEquals(List.of("druid"), List.of(String.valueOf(profiles).split(",")));
    }
}