From caa5f127209682c3b863e380921c10b8bd82ccb7 Mon Sep 17 00:00:00 2001 From: KomachiSion Date: Thu, 22 Aug 2024 10:07:24 +0800 Subject: [PATCH 1/2] Fix unit test error. --- .../impl/derby/ConfigInfoMapperByDerbyTest.java | 6 +++--- .../derby/ConfigInfoTagsRelationMapperByDerbyTest.java | 10 +++++----- .../impl/mysql/ConfigInfoMapperByMySqlTest.java | 6 +++--- .../mysql/ConfigTagsRelationMapperByMySqlTest.java | 10 +++++----- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoMapperByDerbyTest.java b/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoMapperByDerbyTest.java index 6acacee8aae..4856c1dfc5e 100644 --- a/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoMapperByDerbyTest.java +++ b/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoMapperByDerbyTest.java @@ -263,15 +263,15 @@ void testFindConfigInfoBaseByGroupFetchRows() { @Test void testFindConfigInfoLike4PageCountRows() { MapperResult mapperResult = configInfoMapperByDerby.findConfigInfoLike4PageCountRows(context); - assertEquals("SELECT count(*) FROM config_info WHERE tenant_id LIKE ? AND app_name = ? ", mapperResult.getSql()); + assertEquals("SELECT count(*) FROM config_info WHERE tenant_id LIKE ? AND app_name = ? ", mapperResult.getSql()); assertArrayEquals(new Object[] {tenantId, appName}, mapperResult.getParamList().toArray()); } @Test void testFindConfigInfoLike4PageFetchRows() { MapperResult mapperResult = configInfoMapperByDerby.findConfigInfoLike4PageFetchRows(context); - assertEquals(mapperResult.getSql(), "SELECT id,data_id,group_id,tenant_id,app_name,content,encrypted_data_key FROM config_info " - + "WHERE tenant_id LIKE ? AND app_name = ? OFFSET " + startRow + " ROWS FETCH NEXT " + pageSize + " ROWS ONLY"); + assertEquals(mapperResult.getSql(), "SELECT id,data_id,group_id,tenant_id,app_name,content,encrypted_data_key,type FROM config_info " + + "WHERE tenant_id LIKE ? AND app_name = ? OFFSET " + startRow + " ROWS FETCH NEXT " + pageSize + " ROWS ONLY"); assertArrayEquals(new Object[] {tenantId, appName}, mapperResult.getParamList().toArray()); } diff --git a/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoTagsRelationMapperByDerbyTest.java b/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoTagsRelationMapperByDerbyTest.java index 0dbad5e6b36..9fd51b29ee3 100644 --- a/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoTagsRelationMapperByDerbyTest.java +++ b/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/derby/ConfigInfoTagsRelationMapperByDerbyTest.java @@ -56,7 +56,7 @@ void setUp() throws Exception { @Test void testFindConfigInfo4PageCountRows() { MapperResult mapperResult = configInfoTagsRelationMapperByDerby.findConfigInfoLike4PageCountRows(context); - assertEquals(mapperResult.getSql(), "SELECT count(*) FROM config_info a LEFT JOIN config_tags_relation b ON a.id=b.id WHERE " + assertEquals(mapperResult.getSql(), "SELECT count(*) FROM config_info a LEFT JOIN config_tags_relation b ON a.id=b.id WHERE " + "a.tenant_id LIKE ? AND b.tag_name IN (?, ?, ?, ?, ?) "); List list = CollectionUtils.list(tenantId); list.addAll(Arrays.asList(tagArr)); @@ -78,8 +78,8 @@ void testFindConfigInfo4PageFetchRows() { @Test void testFindConfigInfoLike4PageCountRows() { MapperResult mapperResult = configInfoTagsRelationMapperByDerby.findConfigInfoLike4PageCountRows(context); - assertEquals(mapperResult.getSql(), "SELECT count(*) FROM config_info a LEFT JOIN config_tags_relation b ON a.id=b.id " - + "WHERE a.tenant_id LIKE ? AND b.tag_name IN (?, ?, ?, ?, ?) "); + assertEquals(mapperResult.getSql(), "SELECT count(*) FROM config_info a LEFT JOIN config_tags_relation b ON a.id=b.id " + + "WHERE a.tenant_id LIKE ? AND b.tag_name IN (?, ?, ?, ?, ?) "); List list = CollectionUtils.list(tenantId); list.addAll(Arrays.asList(tagArr)); assertArrayEquals(mapperResult.getParamList().toArray(), list.toArray()); @@ -88,8 +88,8 @@ void testFindConfigInfoLike4PageCountRows() { @Test void tsetFindConfigInfoLike4PageFetchRows() { MapperResult mapperResult = configInfoTagsRelationMapperByDerby.findConfigInfoLike4PageFetchRows(context); - assertEquals(mapperResult.getSql(), "SELECT a.ID,a.data_id,a.group_id,a.tenant_id,a.app_name,a.content FROM config_info a " - + "LEFT JOIN config_tags_relation b ON a.id=b.id WHERE a.tenant_id LIKE ? AND b.tag_name " + assertEquals(mapperResult.getSql(), "SELECT a.ID,a.data_id,a.group_id,a.tenant_id,a.app_name,a.content,a.type FROM config_info a " + + "LEFT JOIN config_tags_relation b ON a.id=b.id WHERE a.tenant_id LIKE ? AND b.tag_name " + "IN (?, ?, ?, ?, ?) OFFSET 0 ROWS FETCH NEXT 5 ROWS ONLY"); List list = CollectionUtils.list(tenantId); list.addAll(Arrays.asList(tagArr)); diff --git a/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigInfoMapperByMySqlTest.java b/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigInfoMapperByMySqlTest.java index 190f00ae2f2..91d1facd6ec 100644 --- a/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigInfoMapperByMySqlTest.java +++ b/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigInfoMapperByMySqlTest.java @@ -261,15 +261,15 @@ void testFindConfigInfoBaseByGroupFetchRows() { @Test void testFindConfigInfoLike4PageCountRows() { MapperResult mapperResult = configInfoMapperByMySql.findConfigInfoLike4PageCountRows(context); - assertEquals("SELECT count(*) FROM config_info WHERE tenant_id LIKE ? AND app_name = ? ", mapperResult.getSql()); + assertEquals("SELECT count(*) FROM config_info WHERE tenant_id LIKE ? AND app_name = ? ", mapperResult.getSql()); assertArrayEquals(new Object[] {tenantId, appName}, mapperResult.getParamList().toArray()); } @Test void testFindConfigInfoLike4PageFetchRows() { MapperResult mapperResult = configInfoMapperByMySql.findConfigInfoLike4PageFetchRows(context); - assertEquals(mapperResult.getSql(), "SELECT id,data_id,group_id,tenant_id,app_name,content,encrypted_data_key FROM config_info " - + "WHERE tenant_id LIKE ? AND app_name = ? LIMIT " + startRow + "," + pageSize); + assertEquals(mapperResult.getSql(), "SELECT id,data_id,group_id,tenant_id,app_name,content,encrypted_data_key,type FROM config_info " + + "WHERE tenant_id LIKE ? AND app_name = ? LIMIT " + startRow + "," + pageSize); assertArrayEquals(new Object[] {tenantId, appName}, mapperResult.getParamList().toArray()); } diff --git a/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigTagsRelationMapperByMySqlTest.java b/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigTagsRelationMapperByMySqlTest.java index bd4bda73c78..e9ab1aa83f0 100644 --- a/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigTagsRelationMapperByMySqlTest.java +++ b/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/mysql/ConfigTagsRelationMapperByMySqlTest.java @@ -56,7 +56,7 @@ void setUp() throws Exception { @Test void testFindConfigInfoLike4PageCountRows() { MapperResult mapperResult = configTagsRelationMapperByMySql.findConfigInfoLike4PageCountRows(context); - assertEquals(mapperResult.getSql(), "SELECT count(*) FROM config_info a LEFT JOIN config_tags_relation b ON a.id=b.id WHERE " + assertEquals(mapperResult.getSql(), "SELECT count(*) FROM config_info a LEFT JOIN config_tags_relation b ON a.id=b.id WHERE " + "a.tenant_id LIKE ? AND b.tag_name IN (?, ?, ?, ?, ?) "); List list = CollectionUtils.list(tenantId); list.addAll(Arrays.asList(tagArr)); @@ -101,8 +101,8 @@ void testFindConfigInfoLike4PageCountRowss() { context.putWhereParameter(FieldConstant.APP_NAME, "AppName1"); context.putWhereParameter(FieldConstant.CONTENT, "Content1"); MapperResult mapperResult = configTagsRelationMapperByMySql.findConfigInfoLike4PageCountRows(context); - assertEquals("SELECT count(*) FROM config_info a LEFT JOIN config_tags_relation b ON a.id=b.id " - + "WHERE a.tenant_id LIKE ? AND a.data_id LIKE ? AND a.group_id LIKE ? AND a.app_name = ? " + assertEquals("SELECT count(*) FROM config_info a LEFT JOIN config_tags_relation b ON a.id=b.id " + + "WHERE a.tenant_id LIKE ? AND a.data_id LIKE ? AND a.group_id LIKE ? AND a.app_name = ? " + "AND a.content LIKE ? AND b.tag_name IN (?, ?, ?, ?, ?) ", mapperResult.getSql()); List list = CollectionUtils.list(tenantId); list.add("dataID1"); @@ -120,8 +120,8 @@ void tsetFindConfigInfoLike4PageFetchRows() { context.putWhereParameter(FieldConstant.APP_NAME, "AppName1"); context.putWhereParameter(FieldConstant.CONTENT, "Content1"); MapperResult mapperResult = configTagsRelationMapperByMySql.findConfigInfoLike4PageFetchRows(context); - assertEquals(mapperResult.getSql(), "SELECT a.id,a.data_id,a.group_id,a.tenant_id,a.app_name,a.content FROM config_info a LEFT JOIN" - + " config_tags_relation b ON a.id=b.id WHERE a.tenant_id LIKE ? AND a.data_id LIKE ? " + assertEquals(mapperResult.getSql(), "SELECT a.id,a.data_id,a.group_id,a.tenant_id,a.app_name,a.content,a.type FROM config_info a LEFT JOIN" + + " config_tags_relation b ON a.id=b.id WHERE a.tenant_id LIKE ? AND a.data_id LIKE ? " + "AND a.group_id LIKE ? AND a.app_name = ? AND a.content LIKE ? AND b.tag_name IN (?, ?, ?, ?, ?) LIMIT " + startRow + "," + pageSize); List list = CollectionUtils.list(tenantId); From 33d37bf5a2f3226677311fd4d7a0ccf6fb9d4834 Mon Sep 17 00:00:00 2001 From: KomachiSion Date: Thu, 22 Aug 2024 10:31:59 +0800 Subject: [PATCH 2/2] Fix unit test error. --- .../nacos/config/server/paramcheck/ParamExtractorTest.java | 2 +- config/src/test/resources/log4j.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/src/test/java/com/alibaba/nacos/config/server/paramcheck/ParamExtractorTest.java b/config/src/test/java/com/alibaba/nacos/config/server/paramcheck/ParamExtractorTest.java index da3c57a289a..bfb157b4fd9 100644 --- a/config/src/test/java/com/alibaba/nacos/config/server/paramcheck/ParamExtractorTest.java +++ b/config/src/test/java/com/alibaba/nacos/config/server/paramcheck/ParamExtractorTest.java @@ -56,7 +56,7 @@ class ParamExtractorTest { void testBlurFilter() throws Exception { MockedStatic mockedStatic = Mockito.mockStatic(EnvUtil.class); final Method check = ConfigController.class.getMethod("fuzzySearchConfig", String.class, String.class, String.class, String.class, - String.class, int.class, int.class); + String.class, String.class, int.class, int.class); ExtractorManager.Extractor annotation = check.getAnnotation(ExtractorManager.Extractor.class); AbstractHttpParamExtractor httpExtractor = Mockito.spy(ExtractorManager.getHttpExtractor(annotation)); diff --git a/config/src/test/resources/log4j.properties b/config/src/test/resources/log4j.properties index fa72fc136a6..3346a21acd2 100644 --- a/config/src/test/resources/log4j.properties +++ b/config/src/test/resources/log4j.properties @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -log4j.rootLogger=DEBUG, ServerDailyRollingFile,stdout +log4j.rootLogger=INFO, ServerDailyRollingFile,stdout log4j.appender.ServerDailyRollingFile=org.apache.log4j.DailyRollingFileAppender log4j.appender.ServerDailyRollingFile.DatePattern='.'yyyy-MM-dd_HH log4j.appender.ServerDailyRollingFile.File=${webapp.root}/WEB-INF/logs/nacos-server.log