Skip to content

Commit 05418be

Browse files
wushiyuanmaimobsywu14
authored andcommitted
test: fix NacosPropertySourceRefreshListener test setup
The tests were adding plain MapPropertySource to propertySources, but the production code checks for NacosPropertySource type. This caused the refresh logic to never execute, resulting in test failures where values weren't updated. Fixed by: 1. Adding NacosPropertySource wrapper to propertySources instead of inner MapPropertySource 2. Specifying "yml" suffix in NacosPropertySource constructor to match test data Signed-off-by: sywu14 <wushiyuanwork@outlook.com>
1 parent 3a7da96 commit 05418be

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

spring-cloud-alibaba-starters/spring-alibaba-nacos-config/src/test/java/com.alibaba.cloud.nacos/refresh/NacosPropertySourceRefreshListenerTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ public void testRefreshWithConfigDataPathNaming() throws NacosException {
9090
initialData.put("app.name", "old-value");
9191
MapPropertySource innerSource = new MapPropertySource(configDataName, initialData);
9292
NacosPropertySource nacosPropertySource = new NacosPropertySource(
93-
Collections.singletonList(innerSource), group, dataId, new Date(), true);
93+
Collections.singletonList(innerSource), group, dataId, new Date(), true, "yml");
9494

95-
propertySources.addLast(innerSource);
95+
propertySources.addLast(nacosPropertySource);
9696

9797
// Mark app as ready
9898
listener.handle(mock(ApplicationReadyEvent.class));
@@ -129,9 +129,9 @@ public void testRefreshWithYmlExtension() throws NacosException {
129129
initialData.put("app.port", "8080");
130130
MapPropertySource innerSource = new MapPropertySource(sourceName, initialData);
131131
NacosPropertySource nacosPropertySource = new NacosPropertySource(
132-
Collections.singletonList(innerSource), group, dataId, new Date(), true);
132+
Collections.singletonList(innerSource), group, dataId, new Date(), true, "yml");
133133

134-
propertySources.addLast(innerSource);
134+
propertySources.addLast(nacosPropertySource);
135135

136136
// Mark app as ready
137137
listener.handle(mock(ApplicationReadyEvent.class));

0 commit comments

Comments
 (0)