From 5266cd93de757afb697b20946d400fca8d91d286 Mon Sep 17 00:00:00 2001 From: mll Date: Thu, 15 Sep 2022 21:32:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A1=AB=E5=85=85=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../liteflow/parser/nacos/NacosXmlELParser.java | 11 ++++++++++- .../liteflow/parser/nacos/util/NacosParserHelper.java | 4 +++- .../test/nacos/NacosWithXmlELSpringbootTest.java | 4 ++-- .../test/resources/nacos/application-xml.properties | 4 ++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/liteflow-rule-plugin/liteflow-rule-nacos/src/main/java/com/yomahub/liteflow/parser/nacos/NacosXmlELParser.java b/liteflow-rule-plugin/liteflow-rule-nacos/src/main/java/com/yomahub/liteflow/parser/nacos/NacosXmlELParser.java index 76e6f450..1b36f25d 100644 --- a/liteflow-rule-plugin/liteflow-rule-nacos/src/main/java/com/yomahub/liteflow/parser/nacos/NacosXmlELParser.java +++ b/liteflow-rule-plugin/liteflow-rule-nacos/src/main/java/com/yomahub/liteflow/parser/nacos/NacosXmlELParser.java @@ -40,11 +40,20 @@ public class NacosXmlELParser extends ClassXmlFlowELParser { if (StrUtil.isBlank(nacosParserVO.getServerAddr())){ nacosParserVO.setServerAddr("127.0.0.1:8848"); } + if (StrUtil.isBlank(nacosParserVO.getNamespace())){ + nacosParserVO.setNamespace(""); + } if (StrUtil.isBlank(nacosParserVO.getDataId())){ nacosParserVO.setDataId("LiteFLow"); } if (StrUtil.isBlank(nacosParserVO.getGroup())){ - nacosParserVO.setGroup("LiteFLowConfig"); + nacosParserVO.setGroup("LITE_FLOW_GROUP"); + } + if (StrUtil.isBlank(nacosParserVO.getUsername())){ + nacosParserVO.setUsername(""); + } + if (StrUtil.isBlank(nacosParserVO.getPassword())){ + nacosParserVO.setPassword(""); } helper = new NacosParserHelper(nacosParserVO, parseConsumer); }catch (Exception e){ diff --git a/liteflow-rule-plugin/liteflow-rule-nacos/src/main/java/com/yomahub/liteflow/parser/nacos/util/NacosParserHelper.java b/liteflow-rule-plugin/liteflow-rule-nacos/src/main/java/com/yomahub/liteflow/parser/nacos/util/NacosParserHelper.java index dd58cdfc..3da1102e 100644 --- a/liteflow-rule-plugin/liteflow-rule-nacos/src/main/java/com/yomahub/liteflow/parser/nacos/util/NacosParserHelper.java +++ b/liteflow-rule-plugin/liteflow-rule-nacos/src/main/java/com/yomahub/liteflow/parser/nacos/util/NacosParserHelper.java @@ -43,6 +43,9 @@ public class NacosParserHelper { try{ Properties properties = new Properties(); properties.put(PropertyKeyConst.SERVER_ADDR, nacosParserVO.getServerAddr()); + properties.put(PropertyKeyConst.NAMESPACE,nacosParserVO.getNamespace()); + properties.put(PropertyKeyConst.USERNAME,nacosParserVO.getUsername()); + properties.put(PropertyKeyConst.PASSWORD,nacosParserVO.getPassword()); this.configService = NacosFactory.createConfigService(properties); CONFIG_MAP.put("Content",configService.getConfig(nacosParserVO.getDataId(), nacosParserVO.getGroup(), 3000L)); }catch (Exception e){ @@ -86,7 +89,6 @@ public class NacosParserHelper { } }); }catch (Exception ex){ - LOG.error("listener Exception {} " , ex.getMessage()); throw new NacosException(ex.getMessage()); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nacos-springboot/src/test/java/com/yomahub/liteflow/test/nacos/NacosWithXmlELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-nacos-springboot/src/test/java/com/yomahub/liteflow/test/nacos/NacosWithXmlELSpringbootTest.java index fbc905ea..0407f2de 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nacos-springboot/src/test/java/com/yomahub/liteflow/test/nacos/NacosWithXmlELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nacos-springboot/src/test/java/com/yomahub/liteflow/test/nacos/NacosWithXmlELSpringbootTest.java @@ -34,11 +34,11 @@ public class NacosWithXmlELSpringbootTest extends BaseTest { public void testNacosWithXml() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("a==>b==>c", response.getExecuteStepStr()); + System.out.println(" start " + response.getExecuteStepStr()); for (int i = 0 ; i < 10; i ++){ Thread.sleep(10000L); response = flowExecutor.execute2Resp("chain1", "arg"); - System.out.println(" i " + response.getExecuteStepStr()); + System.out.println(" i " + i + response.getExecuteStepStr()); } } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nacos-springboot/src/test/resources/nacos/application-xml.properties b/liteflow-testcase-el/liteflow-testcase-el-nacos-springboot/src/test/resources/nacos/application-xml.properties index a41924a0..8d3ba6bf 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nacos-springboot/src/test/resources/nacos/application-xml.properties +++ b/liteflow-testcase-el/liteflow-testcase-el-nacos-springboot/src/test/resources/nacos/application-xml.properties @@ -1,3 +1,3 @@ -#liteflow.rule-source-ext-data={"serverAddr":"192.168.10.147:8848"} +liteflow.rule-source-ext-data={"serverAddr":"192.168.10.147:8848","dataId":"LiteFlow","group":"LITE_FLOW_GROUP"} #liteflow.rule-source-ext-data={"serverAddr":"192.168.10.147:8848","dataId":"LiteFlow","group":"LITE_FLOW_GROUP"} -liteflow.rule-source-ext-data={"serverAddr":"192.168.10.147:8848","dataId":"LiteFlow","group":"LITE_FLOW_GROUP","namespace":"","username":"","password":""} \ No newline at end of file +#liteflow.rule-source-ext-data={"serverAddr":"192.168.10.147:8848","dataId":"LiteFlow","group":"LITE_FLOW_GROUP","namespace":"","username":"","password":""} \ No newline at end of file