You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by GitBox <gi...@apache.org> on 2022/06/22 07:52:05 UTC

[GitHub] [incubator-shenyu] LiuTianyou opened a new pull request, #3599: [ISSUE #3464] add new feature for mock plugin

LiuTianyou opened a new pull request, #3599:
URL: https://github.com/apache/incubator-shenyu/pull/3599

   #3464 
   add new feature : support generating random data by configuring ${}
   add unit test for mock plugin


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-shenyu] codecov-commenter commented on pull request #3599: [ISSUE #3464] add new feature for mock plugin

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #3599:
URL: https://github.com/apache/incubator-shenyu/pull/3599#issuecomment-1162786627

   # [Codecov](https://codecov.io/gh/apache/incubator-shenyu/pull/3599?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#3599](https://codecov.io/gh/apache/incubator-shenyu/pull/3599?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (27c8be7) into [master](https://codecov.io/gh/apache/incubator-shenyu/commit/f69c5ca32712f7e89de336fa45a777daaa35f3e3?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (f69c5ca) will **decrease** coverage by `0.57%`.
   > The diff coverage is `n/a`.
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #3599      +/-   ##
   ============================================
   - Coverage     62.57%   62.00%   -0.58%     
   + Complexity     5705     5658      -47     
   ============================================
     Files           870      870              
     Lines         24069    24060       -9     
     Branches       2194     2191       -3     
   ============================================
   - Hits          15062    14918     -144     
   - Misses         7606     7734     +128     
   - Partials       1401     1408       +7     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-shenyu/pull/3599?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...plugin/logging/rocketmq/LoggingRocketMQPlugin.java](https://codecov.io/gh/apache/incubator-shenyu/pull/3599/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hlbnl1LXBsdWdpbi9zaGVueXUtcGx1Z2luLWxvZ2dpbmcvc2hlbnl1LXBsdWdpbi1sb2dnaW5nLXJvY2tldG1xL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGVueXUvcGx1Z2luL2xvZ2dpbmcvcm9ja2V0bXEvTG9nZ2luZ1JvY2tldE1RUGx1Z2luLmphdmE=) | `22.72% <0.00%> (-72.73%)` | :arrow_down: |
   | [...ogging/rocketmq/body/LoggingServerHttpRequest.java](https://codecov.io/gh/apache/incubator-shenyu/pull/3599/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hlbnl1LXBsdWdpbi9zaGVueXUtcGx1Z2luLWxvZ2dpbmcvc2hlbnl1LXBsdWdpbi1sb2dnaW5nLXJvY2tldG1xL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGVueXUvcGx1Z2luL2xvZ2dpbmcvcm9ja2V0bXEvYm9keS9Mb2dnaW5nU2VydmVySHR0cFJlcXVlc3QuamF2YQ==) | `0.00% <0.00%> (-20.00%)` | :arrow_down: |
   | [...henyu/admin/service/impl/UpstreamCheckService.java](https://codecov.io/gh/apache/incubator-shenyu/pull/3599/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hlbnl1LWFkbWluL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGVueXUvYWRtaW4vc2VydmljZS9pbXBsL1Vwc3RyZWFtQ2hlY2tTZXJ2aWNlLmphdmE=) | `46.52% <0.00%> (-19.45%)` | :arrow_down: |
   | [...che/shenyu/sync/data/http/HttpSyncDataService.java](https://codecov.io/gh/apache/incubator-shenyu/pull/3599/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hlbnl1LXN5bmMtZGF0YS1jZW50ZXIvc2hlbnl1LXN5bmMtZGF0YS1odHRwL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGVueXUvc3luYy9kYXRhL2h0dHAvSHR0cFN5bmNEYXRhU2VydmljZS5qYXZh) | `70.40% <0.00%> (-19.39%)` | :arrow_down: |
   | [...he/shenyu/common/timer/HierarchicalWheelTimer.java](https://codecov.io/gh/apache/incubator-shenyu/pull/3599/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hlbnl1LWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hlbnl1L2NvbW1vbi90aW1lci9IaWVyYXJjaGljYWxXaGVlbFRpbWVyLmphdmE=) | `68.00% <0.00%> (-18.00%)` | :arrow_down: |
   | [...va/org/apache/shenyu/common/timer/TimingWheel.java](https://codecov.io/gh/apache/incubator-shenyu/pull/3599/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hlbnl1LWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hlbnl1L2NvbW1vbi90aW1lci9UaW1pbmdXaGVlbC5qYXZh) | `73.80% <0.00%> (-16.67%)` | :arrow_down: |
   | [...yu/sync/data/http/refresh/AbstractDataRefresh.java](https://codecov.io/gh/apache/incubator-shenyu/pull/3599/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hlbnl1LXN5bmMtZGF0YS1jZW50ZXIvc2hlbnl1LXN5bmMtZGF0YS1odHRwL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGVueXUvc3luYy9kYXRhL2h0dHAvcmVmcmVzaC9BYnN0cmFjdERhdGFSZWZyZXNoLmphdmE=) | `68.96% <0.00%> (-13.80%)` | :arrow_down: |
   | [...logging/elasticsearch/entity/ShenyuRequestLog.java](https://codecov.io/gh/apache/incubator-shenyu/pull/3599/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hlbnl1LXBsdWdpbi9zaGVueXUtcGx1Z2luLWxvZ2dpbmcvc2hlbnl1LXBsdWdpbi1sb2dnaW5nLWVsYXN0aWNzZWFyY2gvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoZW55dS9wbHVnaW4vbG9nZ2luZy9lbGFzdGljc2VhcmNoL2VudGl0eS9TaGVueXVSZXF1ZXN0TG9nLmphdmE=) | `86.20% <0.00%> (-13.80%)` | :arrow_down: |
   | [...h/elasticsearch/ElasticSearchLogCollectClient.java](https://codecov.io/gh/apache/incubator-shenyu/pull/3599/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hlbnl1LXBsdWdpbi9zaGVueXUtcGx1Z2luLWxvZ2dpbmcvc2hlbnl1LXBsdWdpbi1sb2dnaW5nLWVsYXN0aWNzZWFyY2gvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoZW55dS9wbHVnaW4vbG9nZ2luZy9lbGFzdGljc2VhcmNoL2VsYXN0aWNzZWFyY2gvRWxhc3RpY1NlYXJjaExvZ0NvbGxlY3RDbGllbnQuamF2YQ==) | `50.00% <0.00%> (-13.05%)` | :arrow_down: |
   | [...a/org/apache/shenyu/common/utils/VersionUtils.java](https://codecov.io/gh/apache/incubator-shenyu/pull/3599/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hlbnl1LWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hlbnl1L2NvbW1vbi91dGlscy9WZXJzaW9uVXRpbHMuamF2YQ==) | `67.85% <0.00%> (-10.72%)` | :arrow_down: |
   | ... and [19 more](https://codecov.io/gh/apache/incubator-shenyu/pull/3599/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-shenyu/pull/3599?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-shenyu/pull/3599?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [f69c5ca...27c8be7](https://codecov.io/gh/apache/incubator-shenyu/pull/3599?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-shenyu] LiuTianyou commented on a diff in pull request #3599: [ISSUE #3464] add new feature for mock plugin

Posted by GitBox <gi...@apache.org>.
LiuTianyou commented on code in PR #3599:
URL: https://github.com/apache/incubator-shenyu/pull/3599#discussion_r911590729


##########
shenyu-plugin/shenyu-plugin-api/src/main/java/org/apache/shenyu/plugin/api/utils/WebFluxResultUtils.java:
##########
@@ -72,21 +70,7 @@ public static Mono<Void> result(final ServerWebExchange exchange, final Object r
             .bufferFactory().wrap(bytes))
             .doOnNext(data -> exchange.getResponse().getHeaders().setContentLength(data.readableByteCount())));
     }
-
-    /**
-     * Response result and support specify the http status code .
-     *
-     * @param exchange   the exchange

Review Comment:
   I encapsulated resultCustomStatusCode by calling the WebFluxResultUtils#result method before. However, the result method will set the MIME type. Although the data of the Mock is a string, it should be set to application/json, so I moved this part to the doExecute of the MockPlugin. The operation of response will be more flexible



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-shenyu] yu199195 commented on a diff in pull request #3599: [ISSUE #3464] add new feature for mock plugin

Posted by GitBox <gi...@apache.org>.
yu199195 commented on code in PR #3599:
URL: https://github.com/apache/incubator-shenyu/pull/3599#discussion_r909923671


##########
shenyu-plugin/shenyu-plugin-mock/src/main/java/org/apache/shenyu/plugin/mock/util/RandomUtil.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.plugin.mock.util;
+
+import java.util.Random;
+import org.apache.commons.lang3.RandomStringUtils;
+
+/**
+ * Random Util.
+ */
+public class RandomUtil {
+    
+    private static final Random RANDOM = new Random();

Review Comment:
   Are there threads that are unsafe?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-shenyu] LiuTianyou commented on pull request #3599: [ISSUE #3464] add new feature for mock plugin

Posted by GitBox <gi...@apache.org>.
LiuTianyou commented on PR #3599:
URL: https://github.com/apache/incubator-shenyu/pull/3599#issuecomment-1169851768

   @yu199195 I modified the code as suggested by the last review, please review it


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-shenyu] yu199195 commented on a diff in pull request #3599: [ISSUE #3464] add new feature for mock plugin

Posted by GitBox <gi...@apache.org>.
yu199195 commented on code in PR #3599:
URL: https://github.com/apache/incubator-shenyu/pull/3599#discussion_r903516777


##########
shenyu-plugin/shenyu-plugin-mock/src/main/java/org/apache/shenyu/plugin/mock/generator/CnameGenerator.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.plugin.mock.generator;
+
+import java.util.Random;
+
+/**
+ * Chinese name generator.
+ */
+public class CnameGenerator extends AbstractGenerator<String> {
+    
+    private static final String[] FIRST_NAME = {"李", "王", "张", "刘", "陈", "杨", "赵", "黄", "周", "吴",

Review Comment:
   whats mean? it be remove



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-shenyu] yu199195 commented on a diff in pull request #3599: [ISSUE #3464] add new feature for mock plugin

Posted by GitBox <gi...@apache.org>.
yu199195 commented on code in PR #3599:
URL: https://github.com/apache/incubator-shenyu/pull/3599#discussion_r909933343


##########
shenyu-plugin/shenyu-plugin-mock/src/test/java/org/apache/shenyu/plugin/mock/generator/RandomIntGeneratorTest.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.plugin.mock.generator;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * The test case for {@link RandomIntGenerator}.
+ */
+class RandomIntGeneratorTest {
+    
+    private final RandomIntGenerator generator = new RandomIntGenerator();
+    
+    @Test
+    void generate() {

Review Comment:
   add public 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-shenyu] LiuTianyou commented on a diff in pull request #3599: [ISSUE #3464] add new feature for mock plugin

Posted by GitBox <gi...@apache.org>.
LiuTianyou commented on code in PR #3599:
URL: https://github.com/apache/incubator-shenyu/pull/3599#discussion_r903530899


##########
shenyu-plugin/shenyu-plugin-mock/src/main/java/org/apache/shenyu/plugin/mock/generator/CnameGenerator.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.plugin.mock.generator;
+
+import java.util.Random;
+
+/**
+ * Chinese name generator.
+ */
+public class CnameGenerator extends AbstractGenerator<String> {
+    
+    private static final String[] FIRST_NAME = {"李", "王", "张", "刘", "陈", "杨", "赵", "黄", "周", "吴",

Review Comment:
   Initialize some Chinese surnames and common characters in Chinese names, so that the randomly generated name looks more like a normal name, I will add some comments here



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-shenyu] yu199195 commented on a diff in pull request #3599: [ISSUE #3464] add new feature for mock plugin

Posted by GitBox <gi...@apache.org>.
yu199195 commented on code in PR #3599:
URL: https://github.com/apache/incubator-shenyu/pull/3599#discussion_r909915214


##########
shenyu-plugin/shenyu-plugin-mock/src/main/java/org/apache/shenyu/plugin/mock/util/GenerateUtil.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.plugin.mock.util;
+
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.apache.shenyu.plugin.base.mock.Generator;
+import org.apache.shenyu.spi.ExtensionLoader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * GenerateUtil.
+ */
+public final class GenerateUtil {

Review Comment:
   rename to GenerateFactory?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-shenyu] yu199195 commented on a diff in pull request #3599: [ISSUE #3464] add new feature for mock plugin

Posted by GitBox <gi...@apache.org>.
yu199195 commented on code in PR #3599:
URL: https://github.com/apache/incubator-shenyu/pull/3599#discussion_r909931531


##########
shenyu-plugin/shenyu-plugin-mock/src/test/java/org/apache/shenyu/plugin/mock/generator/EnStringGeneratorTest.java:
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.plugin.mock.generator;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * The test case for {@link EnStringGenerator}.
+ */
+class EnStringGeneratorTest {

Review Comment:
   add public final



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-shenyu] JooKS-me commented on pull request #3599: [ISSUE #3464] add new feature for mock plugin

Posted by GitBox <gi...@apache.org>.
JooKS-me commented on PR #3599:
URL: https://github.com/apache/incubator-shenyu/pull/3599#issuecomment-1166200304

   @LiuTianyou Pls merge master to resolve integration-test error, see https://github.com/apache/incubator-shenyu/pull/3611


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-shenyu] yu199195 commented on a diff in pull request #3599: [ISSUE #3464] add new feature for mock plugin

Posted by GitBox <gi...@apache.org>.
yu199195 commented on code in PR #3599:
URL: https://github.com/apache/incubator-shenyu/pull/3599#discussion_r909930091


##########
shenyu-plugin/shenyu-plugin-mock/src/test/java/org/apache/shenyu/plugin/mock/generator/EmailGeneratorTest.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.plugin.mock.generator;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * The test case for {@link EmailGenerator}.
+ *
+ * @date 2022/6/20 14:29

Review Comment:
   remove @date 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-shenyu] yu199195 commented on a diff in pull request #3599: [ISSUE #3464] add new feature for mock plugin

Posted by GitBox <gi...@apache.org>.
yu199195 commented on code in PR #3599:
URL: https://github.com/apache/incubator-shenyu/pull/3599#discussion_r909899741


##########
shenyu-plugin/shenyu-plugin-api/src/main/java/org/apache/shenyu/plugin/api/utils/WebFluxResultUtils.java:
##########
@@ -72,21 +70,7 @@ public static Mono<Void> result(final ServerWebExchange exchange, final Object r
             .bufferFactory().wrap(bytes))
             .doOnNext(data -> exchange.getResponse().getHeaders().setContentLength(data.readableByteCount())));
     }
-
-    /**
-     * Response result and support specify the http status code .
-     *
-     * @param exchange   the exchange

Review Comment:
   why remove this method



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-shenyu] yu199195 merged pull request #3599: [ISSUE #3464] add new feature for mock plugin

Posted by GitBox <gi...@apache.org>.
yu199195 merged PR #3599:
URL: https://github.com/apache/incubator-shenyu/pull/3599


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-shenyu] yu199195 commented on a diff in pull request #3599: [ISSUE #3464] add new feature for mock plugin

Posted by GitBox <gi...@apache.org>.
yu199195 commented on code in PR #3599:
URL: https://github.com/apache/incubator-shenyu/pull/3599#discussion_r909919178


##########
shenyu-plugin/shenyu-plugin-mock/src/main/java/org/apache/shenyu/plugin/mock/util/GenerateUtil.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.plugin.mock.util;
+
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.apache.shenyu.plugin.base.mock.Generator;
+import org.apache.shenyu.spi.ExtensionLoader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * GenerateUtil.
+ */
+public final class GenerateUtil {
+    
+    /**
+     * Regular expression to extract placeholders.
+     */
+    private static final Pattern RULE_PATTERN = Pattern
+        .compile("(\\$\\{.+?})", Pattern.MULTILINE);
+    
+    private static final Logger LOG = LoggerFactory.getLogger(GenerateUtil.class);
+    
+    /**
+     * Regular expression to extract rule content.
+     */
+    private static final Pattern RULE_CONTENT_PATTERN = Pattern
+        .compile("^\\$\\{(.+?)}$", Pattern.MULTILINE);
+    
+    /**
+     * cache of generators.
+     */
+    private static final Map<String, Generator<?>> GENERATORS = new ConcurrentHashMap<>();
+    
+    private GenerateUtil() {
+    }
+    
+    private static Generator<?> getGenerator(final String ruleName, final String rule) {
+        Generator<?> generator = GENERATORS.get(ruleName);
+        if (generator == null) {
+            try {
+                generator = ExtensionLoader.getExtensionLoader(Generator.class).getJoin(ruleName);
+                GENERATORS.put(ruleName, generator);
+                return generator;
+            } catch (IllegalArgumentException e) {
+                LOG.warn("{} can not parse,please check", rule);
+            }
+        }
+        return generator;
+    }
+    
+    private static Object generate(final String rule) {
+        final Matcher matcher = RULE_CONTENT_PATTERN.matcher(rule);
+        if (matcher.find()) {
+            String ruleContent = matcher.group(1);
+            String ruleName = ruleContent.split("\\|")[0];
+            Generator<?> generator = getGenerator(ruleName, rule);
+            if (generator == null || !generator.match(ruleContent)) {
+                return rule;
+            }
+            generator.parseRule(ruleContent);
+            return generator.generate();
+        } else {
+            return rule;
+        }
+    }
+    
+    /**
+     * replace placeholder in content.
+     *
+     * @param content response content.
+     * @return replace the content after the placeholder.
+     */
+    public static String dealRule(final String content) {
+        String afterDeal = content;
+        final Matcher matcher = RULE_PATTERN.matcher(afterDeal);
+        while (matcher.find()) {
+            String placeHolder = matcher.group(0);
+            Object generateData = generate(placeHolder);
+            if (Objects.equals(generateData, placeHolder)) {
+                continue;
+            }
+            String toString = String.valueOf(generateData);
+            if (generateData instanceof String) {
+                toString = String.format("\"%s\"", toString);
+            }
+            placeHolder = placeHolder.replaceAll("([$|{}\\]\\[])", "\\\\$1");
+            afterDeal = afterDeal.replaceFirst(placeHolder, toString);
+        }
+        return afterDeal;
+    }
+    
+}
+
+

Review Comment:
   Delete extra blank lines



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-shenyu] yu199195 commented on a diff in pull request #3599: [ISSUE #3464] add new feature for mock plugin

Posted by GitBox <gi...@apache.org>.
yu199195 commented on code in PR #3599:
URL: https://github.com/apache/incubator-shenyu/pull/3599#discussion_r909912066


##########
shenyu-plugin/shenyu-plugin-mock/src/main/java/org/apache/shenyu/plugin/mock/util/GenerateUtil.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.plugin.mock.util;
+
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.apache.shenyu.plugin.base.mock.Generator;
+import org.apache.shenyu.spi.ExtensionLoader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * GenerateUtil.
+ */
+public final class GenerateUtil {
+    
+    /**
+     * Regular expression to extract placeholders.
+     */
+    private static final Pattern RULE_PATTERN = Pattern
+        .compile("(\\$\\{.+?})", Pattern.MULTILINE);
+    
+    private static final Logger LOG = LoggerFactory.getLogger(GenerateUtil.class);
+    
+    /**
+     * Regular expression to extract rule content.
+     */
+    private static final Pattern RULE_CONTENT_PATTERN = Pattern
+        .compile("^\\$\\{(.+?)}$", Pattern.MULTILINE);
+    
+    /**
+     * cache of generators.
+     */
+    private static final Map<String, Generator<?>> GENERATORS = new ConcurrentHashMap<>();

Review Comment:
   not used map stroe Generator



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-shenyu] yu199195 commented on a diff in pull request #3599: [ISSUE #3464] add new feature for mock plugin

Posted by GitBox <gi...@apache.org>.
yu199195 commented on code in PR #3599:
URL: https://github.com/apache/incubator-shenyu/pull/3599#discussion_r909927277


##########
shenyu-plugin/shenyu-plugin-mock/src/test/java/org/apache/shenyu/plugin/mock/generator/CurrentTimeGeneratorTest.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.plugin.mock.generator;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+/**
+ * The test case for {@link CurrentTimeGenerator}.
+ */
+public class CurrentTimeGeneratorTest {

Review Comment:
   add final



##########
shenyu-plugin/shenyu-plugin-mock/src/test/java/org/apache/shenyu/plugin/mock/generator/EmailGeneratorTest.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.plugin.mock.generator;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * The test case for {@link EmailGenerator}.
+ *
+ * @date 2022/6/20 14:29
+ */
+class EmailGeneratorTest {

Review Comment:
   add public  final



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-shenyu] yu199195 commented on a diff in pull request #3599: [ISSUE #3464] add new feature for mock plugin

Posted by GitBox <gi...@apache.org>.
yu199195 commented on code in PR #3599:
URL: https://github.com/apache/incubator-shenyu/pull/3599#discussion_r903517303


##########
shenyu-plugin/shenyu-plugin-mock/src/main/java/org/apache/shenyu/plugin/mock/generator/CurrentTimeGenerator.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.plugin.mock.generator;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * current time generator.
+ */
+public class CurrentTimeGenerator extends AbstractGenerator<String> {
+    
+    private static final String DEFAULT_FORMAT = "YYYY-MM-dd HH:mm:ss";
+    
+    private static final Logger LOG = LoggerFactory.getLogger(CurrentTimeGenerator.class);
+    
+    private String format;
+    
+    @Override
+    public String getName() {
+        return "current";
+    }
+    
+    @Override
+    public String generate() {
+        Date now = new Date();

Review Comment:
   used java8 api 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org