This is an automated email from the ASF dual-hosted git repository.
xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new d08039bea [type:refactor] add domain test and polish pom (#4803)
d08039bea is described below
commit d08039beab06b589841d3e4c18b782d6d27479e3
Author: moremind <[email protected]>
AuthorDate: Fri Jul 7 10:59:58 2023 +0800
[type:refactor] add domain test and polish pom (#4803)
* [type:refactor] add domain test and polish pom
* [type:refactor] add domain test and polish pom
* [type:refactor] add domain test and polish pom
* [type:refactor] add domain test and polish pom
* [type:refactor] add domain test and polish pom
* [type:refactor] add domain test and polish pom
* [type:refactor] add domain test and polish pom
---
pom.xml | 2 +-
shenyu-bootstrap/pom.xml | 17 ++--
.../org/apache/shenyu/common/enums/PluginEnum.java | 4 +-
.../integrated/test/http/DividePluginTest.java | 100 ++++++++++++++++++++-
.../shenyu-plugin-logging-clickhouse/pom.xml | 50 ++++++-----
.../shenyu-plugin-logging-tencent-cls/pom.xml | 8 --
.../shenyu-plugin-casdoor/pom.xml | 2 +-
7 files changed, 135 insertions(+), 48 deletions(-)
diff --git a/pom.xml b/pom.xml
index 2a9362190..27d66e554 100644
--- a/pom.xml
+++ b/pom.xml
@@ -173,11 +173,11 @@
<resilience.version>1.7.1</resilience.version>
<sentinel.version>1.8.3</sentinel.version>
<lettuce.version>6.1.2.RELEASE</lettuce.version>
- <aliyun-log.version>0.6.70</aliyun-log.version>
<protobuf-java.version>3.19.6</protobuf-java.version>
<aliyun-log-producer.version>0.3.10</aliyun-log-producer.version>
<tencent-log-sdk.version>1.0.9</tencent-log-sdk.version>
<jsonpath.version>2.4.0</jsonpath.version>
+ <casdoor-java-sdk.version>1.9.0</casdoor-java-sdk.version>
</properties>
<dependencyManagement>
diff --git a/shenyu-bootstrap/pom.xml b/shenyu-bootstrap/pom.xml
index fc909f503..9f3e6c974 100644
--- a/shenyu-bootstrap/pom.xml
+++ b/shenyu-bootstrap/pom.xml
@@ -237,7 +237,7 @@
<artifactId>shenyu-spring-boot-starter-plugin-tcp</artifactId>
<version>${project.version}</version>
</dependency>
-<!-- Tcp Plugin end-->
+ <!--Tcp Plugin end-->
<!--shenyu sofa plugin start-->
<dependency>
@@ -269,14 +269,6 @@
<version>${project.version}</version>
</dependency>
- <!--shenyu key-auth plugin start-->
- <dependency>
- <groupId>org.apache.shenyu</groupId>
- <artifactId>shenyu-spring-boot-starter-plugin-key-auth</artifactId>
- <version>${project.version}</version>
- </dependency>
- <!--shenyu key-auth plugin end -->
-
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
@@ -308,6 +300,13 @@
</dependency>
<!--shenyu springCloud plugin end-->
+ <!--shenyu key-auth plugin start-->
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-spring-boot-starter-plugin-key-auth</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!--shenyu key-auth plugin end -->
<!--shenyu mock plugin start-->
<dependency>
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/enums/PluginEnum.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/enums/PluginEnum.java
index ea0b0d81e..7a9b38784 100644
--- a/shenyu-common/src/main/java/org/apache/shenyu/common/enums/PluginEnum.java
+++ b/shenyu-common/src/main/java/org/apache/shenyu/common/enums/PluginEnum.java
@@ -31,10 +31,12 @@ public enum PluginEnum {
* Global plugin enum.
*/
GLOBAL(-1, 0, "global"),
+
/**
* Tcp plugin enum.
*/
TCP(0, 0, "tcp"),
+
/**
* Mqtt plugin enum.
*/
@@ -114,8 +116,6 @@ public enum PluginEnum {
* Request plugin enum.
*/
REQUEST(120, 0, "request"),
-
-
/**
* GeneralContext plugin enum.
diff --git
a/shenyu-integrated-test/shenyu-integrated-test-http/src/test/java/org/apache/shenyu/integrated/test/http/DividePluginTest.java
b/shenyu-integrated-test/shenyu-integrated-test-http/src/test/java/org/apache/shenyu/integrated/test/http/DividePluginTest.java
index 59b021d69..44e19e3fa 100644
---
a/shenyu-integrated-test/shenyu-integrated-test-http/src/test/java/org/apache/shenyu/integrated/test/http/DividePluginTest.java
+++
b/shenyu-integrated-test/shenyu-integrated-test-http/src/test/java/org/apache/shenyu/integrated/test/http/DividePluginTest.java
@@ -17,14 +17,27 @@
package org.apache.shenyu.integrated.test.http;
-import org.apache.shenyu.integratedtest.common.AbstractTest;
+import com.google.gson.JsonObject;
+import org.apache.shenyu.common.dto.ConditionData;
+import org.apache.shenyu.common.enums.OperatorEnum;
+import org.apache.shenyu.common.enums.ParamTypeEnum;
+import org.apache.shenyu.common.enums.PluginEnum;
+import org.apache.shenyu.integratedtest.common.AbstractPluginDataInit;
import org.apache.shenyu.integratedtest.common.dto.OrderDTO;
import org.apache.shenyu.integratedtest.common.helper.HttpHelper;
+import org.apache.shenyu.web.controller.LocalPluginController.RuleLocalData;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertEquals;
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
-public class DividePluginTest extends AbstractTest {
+public class DividePluginTest extends AbstractPluginDataInit {
@Test
public void testHelloWorld() throws Exception {
@@ -32,4 +45,85 @@ public class DividePluginTest extends AbstractTest {
user = HttpHelper.INSTANCE.postGateway("/http/order/save", user,
OrderDTO.class);
assertEquals("hello world save order", user.getName());
}
+
+ @Test
+ public void testDomain() throws IOException, InterruptedException {
+ String selectorHandle =
"[{\"upstreamHost\":\"localhost\",\"upstreamUrl\":\"jsonplaceholder.typicode.com\","
+ +
"\"protocol\":\"http://\",\"timestamp\":\"0\",\"weight\":50,\"warmup\":\"0\",\"status\":true}]";
+ List<ConditionData> conditionData = Stream.of(1).map(weight -> {
+ ConditionData data = new ConditionData();
+ data.setParamType(ParamTypeEnum.URI.getName());
+ data.setOperator(OperatorEnum.MATCH.getAlias());
+ data.setParamValue("/posts");
+ return data;
+ }).collect(Collectors.toList());
+
+ List<RuleLocalData> ruleLocalDataList = Stream.of(1).map(rule -> {
+ RuleLocalData ruleLocalData = new RuleLocalData();
+ ruleLocalData.setRuleName("test-domain");
+ ruleLocalData.setMatchMode(0);
+ ruleLocalData.setConditionDataList(conditionData);
+
ruleLocalData.setRuleHandler("{\"loadBalance\":\"hash\",\"retryStrategy\":\"current\","
+ +
"\"retry\":\"3\",\"timeout\":3000,\"headerMaxSize\":10240,\"requestMaxSize\":102400}");
+ return ruleLocalData;
+ }).collect(Collectors.toList());
+
+ String message = initSelectorAndRules(PluginEnum.DIVIDE.getName(),
selectorHandle, conditionData, ruleLocalDataList);
+ assertThat(message, is("success"));
+ TimeUnit.SECONDS.sleep(10);
+ JsonObject request = new JsonObject();
+ request.addProperty("userId", 1);
+ JsonPlaceHolderUser user = HttpHelper.INSTANCE.postGateway("/posts",
request, JsonPlaceHolderUser.class);
+ assertEquals("1", user.getUserId());
+ }
+
+ public static class JsonPlaceHolderUser {
+ private String id;
+
+ private String userId;
+
+ public JsonPlaceHolderUser() {
+ }
+
+ public JsonPlaceHolderUser(final String id, final String userId) {
+ this.id = id;
+ this.userId = userId;
+ }
+
+ /**
+ * get id.
+ *
+ * @return id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * set id.
+ *
+ * @param id id
+ */
+ public void setId(final String id) {
+ this.id = id;
+ }
+
+ /**
+ * get user id.
+ *
+ * @return user id
+ */
+ public String getUserId() {
+ return userId;
+ }
+
+ /**
+ * set user id.
+ *
+ * @param userId user id
+ */
+ public void setUserId(final String userId) {
+ this.userId = userId;
+ }
+ }
}
diff --git
a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/pom.xml
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/pom.xml
index d61385903..c17876950 100644
---
a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/pom.xml
+++
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/pom.xml
@@ -16,33 +16,35 @@
~ limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <artifactId>shenyu-plugin-logging</artifactId>
- <groupId>org.apache.shenyu</groupId>
- <version>2.6.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>shenyu-plugin-logging-clickhouse</artifactId>
- <dependencies>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>shenyu-plugin-logging</artifactId>
+ <groupId>org.apache.shenyu</groupId>
+ <version>2.6.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>shenyu-plugin-logging-clickhouse</artifactId>
+ <dependencies>
- <dependency>
- <groupId>com.clickhouse</groupId>
- <artifactId>clickhouse-http-client</artifactId>
- <version>${clickhouse-http-client.version}</version>
- </dependency>
+ <dependency>
+ <groupId>com.clickhouse</groupId>
+ <artifactId>clickhouse-http-client</artifactId>
+ <version>${clickhouse-http-client.version}</version>
+ </dependency>
- <dependency>
- <groupId>org.apache.shenyu</groupId>
- <artifactId>shenyu-plugin-logging-common</artifactId>
- <version>${project.version}</version>
- </dependency>
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-plugin-logging-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
- <dependency>
- <groupId>io.projectreactor</groupId>
- <artifactId>reactor-test</artifactId>
- </dependency>
+ <dependency>
+ <groupId>io.projectreactor</groupId>
+ <artifactId>reactor-test</artifactId>
+ <scope>test</scope>
+ </dependency>
- </dependencies>
+ </dependencies>
</project>
diff --git
a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-tencent-cls/pom.xml
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-tencent-cls/pom.xml
index 4aefd9197..b063eba20 100644
---
a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-tencent-cls/pom.xml
+++
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-tencent-cls/pom.xml
@@ -25,14 +25,6 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>shenyu-plugin-logging-tencent-cls</artifactId>
- <properties>
- <maven.compiler.source>8</maven.compiler.source>
- <maven.compiler.target>8</maven.compiler.target>
- <aliyun-log.version>0.6.70</aliyun-log.version>
- <protobuf-java.version>3.19.2</protobuf-java.version>
- <tencent-log-sdk.version>1.0.9</tencent-log-sdk.version>
- </properties>
-
<dependencies>
<dependency>
<groupId>org.apache.shenyu</groupId>
diff --git a/shenyu-plugin/shenyu-plugin-security/shenyu-plugin-casdoor/pom.xml
b/shenyu-plugin/shenyu-plugin-security/shenyu-plugin-casdoor/pom.xml
index 29790aaee..e2eb35fec 100644
--- a/shenyu-plugin/shenyu-plugin-security/shenyu-plugin-casdoor/pom.xml
+++ b/shenyu-plugin/shenyu-plugin-security/shenyu-plugin-casdoor/pom.xml
@@ -29,7 +29,7 @@
<dependency>
<groupId>org.casbin</groupId>
<artifactId>casdoor-java-sdk</artifactId>
- <version>1.9.0</version>
+ <version>${casdoor-java-sdk.version}</version>
<exclusions>
<exclusion>
<groupId>org.json</groupId>