Skip to content

Commit

Permalink
Fix running problem after upgrade to spring boot 3 (#13029)
Browse files Browse the repository at this point in the history
* Fix running problem after upgrade to spring boot 3

* Fix Unit test problem.
  • Loading branch information
KomachiSion authored Jan 10, 2025
1 parent c6e8c9f commit 76647c4
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,7 @@ ClientConfigMetricResponse handleClientMetricsRequest(ClientConfigMetricRequest
return response;
}

@SuppressWarnings("PMD.MethodTooLongRule")
private void initRpcClientHandler(final RpcClient rpcClientInner) {
/*
* Register Config Change /Config ReSync Handler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void testGetGroupKeyPattern() {

String groupKeyPattern = FuzzyGroupKeyPattern.generatePattern(dataIdPattern, group, namespace);

assertEquals("exampleNamespace>>exampleGroup@@examplePattern*", groupKeyPattern);
assertEquals("exampleNamespace>>exampleGroup>>examplePattern*", groupKeyPattern);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.springframework.mock.env.MockEnvironment;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;

Expand All @@ -47,22 +48,21 @@

class MD5UtilTest {

MockedStatic<EnvUtil> envUtilMockedStatic;

MockedStatic<ConfigCacheService> configCacheServiceMockedStatic;

MockedStatic<Md5ComparatorDelegate> md5ComparatorDelegateMockedStatic;

@BeforeEach
void setUp() {
envUtilMockedStatic = Mockito.mockStatic(EnvUtil.class);
MockEnvironment environment = new MockEnvironment();
environment.setProperty("nacos.config.cache.type", "nacos");
EnvUtil.setEnvironment(environment);
configCacheServiceMockedStatic = Mockito.mockStatic(ConfigCacheService.class);
md5ComparatorDelegateMockedStatic = Mockito.mockStatic(Md5ComparatorDelegate.class);
}

@AfterEach
void tearDown() {
envUtilMockedStatic.close();
configCacheServiceMockedStatic.close();
md5ComparatorDelegateMockedStatic.close();
}
Expand All @@ -81,7 +81,6 @@ void testCompareMd5() {
request.addHeader("Vipserver-Tag", "test");
MockHttpServletResponse response = new MockHttpServletResponse();

envUtilMockedStatic.when(() -> EnvUtil.getProperty("nacos.config.cache.type", "nacos")).thenReturn("nacos");
when(md5ComparatorDelegate.compareMd5(request, response, clientMd5Map)).thenReturn(new ArrayList<>());
MD5Util.compareMd5(request, response, clientMd5Map);

Expand Down Expand Up @@ -138,7 +137,8 @@ void testCompareMd5ResultString() {
void testGetClientMd5Map() {

String configKeysString =
"test0" + MD5Util.WORD_SEPARATOR_CHAR + "test1" + MD5Util.WORD_SEPARATOR_CHAR + "test2" + MD5Util.LINE_SEPARATOR_CHAR;
"test0" + MD5Util.WORD_SEPARATOR_CHAR + "test1" + MD5Util.WORD_SEPARATOR_CHAR + "test2"
+ MD5Util.LINE_SEPARATOR_CHAR;

Map<String, String> actualValueMap = MD5Util.getClientMd5Map(configKeysString);

Expand All @@ -149,8 +149,8 @@ void testGetClientMd5Map() {
@Test
void testGetClientMd5MapForNewProtocol() {
String configKeysString =
"test0" + MD5Util.WORD_SEPARATOR_CHAR + "test1" + MD5Util.WORD_SEPARATOR_CHAR + "test2" + MD5Util.WORD_SEPARATOR_CHAR
+ "test3" + MD5Util.LINE_SEPARATOR_CHAR;
"test0" + MD5Util.WORD_SEPARATOR_CHAR + "test1" + MD5Util.WORD_SEPARATOR_CHAR + "test2"
+ MD5Util.WORD_SEPARATOR_CHAR + "test3" + MD5Util.LINE_SEPARATOR_CHAR;

Map<String, String> actualValueMap = MD5Util.getClientMd5Map(configKeysString);

Expand Down
3 changes: 2 additions & 1 deletion console/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@
<includes>
<include>META-INF/**</include>
<include>static/**</include>
<include>application.properties</include>
<include>nacos-console.properties</include>
<include>nacos-console-banner.txt</include>
<include>org/apache/derby/modules.properties</include>
<include>librocksdbjni-${hints.os.rocksdb}</include>
</includes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void testSubscribeTypes() {
List<Class<? extends Event>> classes = clientServiceIndexesManager.subscribeTypes();

assertNotNull(classes);
assertEquals(7, classes.size());
assertEquals(5, classes.size());
}

@Test
Expand Down

0 comments on commit 76647c4

Please sign in to comment.