Skip to content

Commit

Permalink
test bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunrisea committed Nov 21, 2024
1 parent 392ef61 commit b8dea6a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class ConfigCacheFactoryDelegateTest {
void setUp() {
envUtilMockedStatic = mockStatic(EnvUtil.class);
nacosServiceLoaderMockedStatic = mockStatic(NacosServiceLoader.class);
when(nacosConfigCacheFactory.getConfigCacheFactoryName()).thenReturn("nacos");
}

@AfterEach
Expand All @@ -72,6 +71,7 @@ public void test() {

@Test
public void test2() throws Exception {
when(nacosConfigCacheFactory.getConfigCacheFactoryName()).thenReturn("nacos");
when(nacosConfigCacheFactory.createConfigCache()).thenReturn(new ConfigCache());
when(nacosConfigCacheFactory.createConfigCacheGray()).thenReturn(new ConfigCacheGray());
nacosServiceLoaderMockedStatic.when(() -> NacosServiceLoader.load(ConfigCacheFactory.class))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ class ConfigCachePostProcessorDelegateTest {
void setUp() {
envUtilMockedStatic = mockStatic(EnvUtil.class);
nacosServiceLoaderMockedStatic = mockStatic(NacosServiceLoader.class);
when(mockConfigCacheMd5PostProcessor.getPostProcessorName()).thenReturn("nacos");

}

@AfterEach
Expand All @@ -77,6 +75,7 @@ void test1() {
@Test
void test2()
throws NoSuchFieldException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
when(mockConfigCacheMd5PostProcessor.getPostProcessorName()).thenReturn("nacos");
doNothing().when(mockConfigCacheMd5PostProcessor).postProcess(null, null);
envUtilMockedStatic.when(() -> EnvUtil.getProperty("nacos.config.cache.type", "nacos")).thenReturn("nacos");
nacosServiceLoaderMockedStatic.when(() -> NacosServiceLoader.load(ConfigCachePostProcessor.class))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,23 @@ class MD5UtilTest {

MockedStatic<EnvUtil> envUtilMockedStatic;

MockedStatic<ConfigCacheService> configCacheServiceMockedStatic;

@BeforeEach
void setUp() {
envUtilMockedStatic = Mockito.mockStatic(EnvUtil.class);
configCacheServiceMockedStatic = Mockito.mockStatic(ConfigCacheService.class);
}

@AfterEach
void tearDown() {
envUtilMockedStatic.close();
configCacheServiceMockedStatic.close();
}

@Test
void testCompareMd5() {

final MockedStatic<ConfigCacheService> configCacheServiceMockedStatic = Mockito.mockStatic(ConfigCacheService.class);

when(ConfigCacheService.isUptodate(anyString(), anyString(), anyString(), anyString())).thenReturn(false);

Map<String, String> clientMd5Map = new HashMap<>();
Expand All @@ -78,7 +80,6 @@ void testCompareMd5() {
assertEquals(1, changedGroupKeys.size());
assertEquals("test", changedGroupKeys.get(0));

configCacheServiceMockedStatic.close();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class Md5ComparatorDelegateTest {
void setUp() {
envUtilMockedStatic = mockStatic(EnvUtil.class);
nacosServiceLoaderMockedStatic = mockStatic(NacosServiceLoader.class);
when(nacosMd5Comparator.getMd5ComparatorName()).thenReturn("nacos");
}

@AfterEach
Expand All @@ -84,6 +83,7 @@ public void test() {

@Test
public void test2() throws Exception {
when(nacosMd5Comparator.getMd5ComparatorName()).thenReturn("nacos");
envUtilMockedStatic.when(() -> EnvUtil.getProperty("nacos.config.cache.type", "nacos")).thenReturn("nacos");
nacosServiceLoaderMockedStatic.when(() -> NacosServiceLoader.load(Md5Comparator.class))
.thenReturn(Collections.singletonList(nacosMd5Comparator));
Expand Down

0 comments on commit b8dea6a

Please sign in to comment.