feat:Add test for nacos parser

pull/3828/head
songyanhui 5 months ago
parent f1a7bcf16f
commit 2925b283be

@ -70,9 +70,9 @@ public class NacosDataParserHandlerTest {
when(mockLoader.load(anyString(), any())).thenReturn(Collections.singletonList(mock(PropertySource.class)));
// Mock the SpringFactoriesLoader to return our mocked loader
try (MockedStatic< SpringFactoriesLoader > mocked = mockStatic(SpringFactoriesLoader.class)) {
try (MockedStatic<SpringFactoriesLoader> mocked = mockStatic(SpringFactoriesLoader.class)) {
mocked.when(() -> SpringFactoriesLoader.loadFactories(PropertySourceLoader.class, getClass().getClassLoader()))
.thenReturn(Collections.singletonList(mockLoader));
.thenReturn(Collections.singletonList(mockLoader));
List<PropertySource<?>> propertySources = nacosDataParserHandler.parseNacosData(configName, configValue, extension);
@ -90,9 +90,9 @@ public class NacosDataParserHandlerTest {
when(mockLoader.load(anyString(), any())).thenReturn(Collections.singletonList(mock(PropertySource.class)));
// Mock the SpringFactoriesLoader to return our mocked loader
try (MockedStatic< SpringFactoriesLoader > mocked = mockStatic(SpringFactoriesLoader.class)) {
try (MockedStatic<SpringFactoriesLoader> mocked = mockStatic(SpringFactoriesLoader.class)) {
mocked.when(() -> SpringFactoriesLoader.loadFactories(PropertySourceLoader.class, getClass().getClassLoader()))
.thenReturn(Collections.singletonList(mockLoader));
.thenReturn(Collections.singletonList(mockLoader));
List<PropertySource<?>> propertySources = nacosDataParserHandler.parseNacosData(configName, configValue, extension);
@ -110,9 +110,9 @@ public class NacosDataParserHandlerTest {
when(mockLoader.load(anyString(), any())).thenReturn(Collections.singletonList(mock(PropertySource.class)));
// Mock the SpringFactoriesLoader to return our mocked loader
try (MockedStatic< SpringFactoriesLoader > mocked = mockStatic(SpringFactoriesLoader.class)) {
try (MockedStatic<SpringFactoriesLoader> mocked = mockStatic(SpringFactoriesLoader.class)) {
mocked.when(() -> SpringFactoriesLoader.loadFactories(PropertySourceLoader.class, getClass().getClassLoader()))
.thenReturn(Collections.singletonList(mockLoader));
.thenReturn(Collections.singletonList(mockLoader));
List<PropertySource<?>> propertySources = nacosDataParserHandler.parseNacosData(configName, configValue, extension);

Loading…
Cancel
Save