mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
fix tests
This commit is contained in:
parent
7323880c01
commit
a5905307f0
@ -39,58 +39,59 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
public class NacosConfigAutoConfigurationTests {
|
||||
|
||||
private ConfigurableApplicationContext context;
|
||||
private ConfigurableApplicationContext context;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
this.context = new SpringApplicationBuilder(
|
||||
NacosConfigBootstrapConfiguration.class,
|
||||
NacosConfigAutoConfiguration.class,
|
||||
TestConfiguration.class)
|
||||
.web(WebApplicationType.NONE).run(
|
||||
"--spring.cloud.config.enabled=true",
|
||||
"--spring.cloud.nacos.config.server-addr=127.0.0.1:8080",
|
||||
"--spring.cloud.nacos.config.prefix=myapp");
|
||||
}
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
this.context = new SpringApplicationBuilder(
|
||||
NacosConfigBootstrapConfiguration.class,
|
||||
NacosConfigAutoConfiguration.class, TestConfiguration.class)
|
||||
.web(WebApplicationType.NONE)
|
||||
.run("--spring.application.name=myapp",
|
||||
"--spring.cloud.config.enabled=true",
|
||||
"--spring.cloud.nacos.config.server-addr=127.0.0.1:8080",
|
||||
"--spring.cloud.nacos.config.prefix=test");
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
}
|
||||
}
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNacosConfigProperties() {
|
||||
@Test
|
||||
public void testNacosConfigProperties() {
|
||||
|
||||
NacosConfigProperties nacosConfigProperties = this.context.getParent().getBean(NacosConfigProperties.class);
|
||||
assertThat(nacosConfigProperties.getFileExtension()).isEqualTo("properties");
|
||||
assertThat(nacosConfigProperties.getPrefix()).isEqualTo("myapp");
|
||||
NacosConfigProperties nacosConfigProperties = this.context.getParent()
|
||||
.getBean(NacosConfigProperties.class);
|
||||
assertThat(nacosConfigProperties.getFileExtension()).isEqualTo("properties");
|
||||
assertThat(nacosConfigProperties.getPrefix()).isEqualTo("test");
|
||||
assertThat(nacosConfigProperties.getName()).isEqualTo("myapp");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNacosRefreshProperties() {
|
||||
|
||||
@Test
|
||||
public void testNacosRefreshProperties() {
|
||||
NacosRefreshProperties nacosRefreshProperties = this.context
|
||||
.getBean(NacosRefreshProperties.class);
|
||||
assertThat(nacosRefreshProperties.isEnabled()).isEqualTo(true);
|
||||
|
||||
NacosRefreshProperties nacosRefreshProperties = this.context.getBean(NacosRefreshProperties.class);
|
||||
assertThat(nacosRefreshProperties.isEnabled()).isEqualTo(true);
|
||||
}
|
||||
|
||||
}
|
||||
@Configuration
|
||||
@AutoConfigureBefore(NacosConfigAutoConfiguration.class)
|
||||
static class TestConfiguration {
|
||||
|
||||
@Configuration
|
||||
@AutoConfigureBefore(NacosConfigAutoConfiguration.class)
|
||||
static class TestConfiguration{
|
||||
@Autowired
|
||||
ConfigurableApplicationContext context;
|
||||
|
||||
@Bean
|
||||
ContextRefresher contextRefresher() {
|
||||
return new ContextRefresher(context, new RefreshScope());
|
||||
}
|
||||
|
||||
@Autowired
|
||||
ConfigurableApplicationContext context;
|
||||
|
||||
@Bean
|
||||
ContextRefresher contextRefresher(){
|
||||
return new ContextRefresher(context, new RefreshScope());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -43,9 +43,10 @@ public class NacosConfigBootstrapConfigurationTests {
|
||||
public void setUp() throws Exception {
|
||||
this.context = new SpringApplicationBuilder(
|
||||
NacosConfigBootstrapConfiguration.class).web(WebApplicationType.NONE).run(
|
||||
"--spring.application.name=myapp",
|
||||
"--spring.cloud.config.enabled=true",
|
||||
"--spring.cloud.nacos.config.server-addr=127.0.0.1:8080",
|
||||
"--spring.cloud.nacos.config.prefix=myapp");
|
||||
"--spring.cloud.nacos.config.prefix=test");
|
||||
}
|
||||
|
||||
@After
|
||||
|
Loading…
x
Reference in New Issue
Block a user