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/incubator-shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 62a1424 feature : add integrated test for spring cloud plugin (#1891)
62a1424 is described below
commit 62a142431176dba277c9d15832d9f5e6c9f7a66a
Author: luoxiaolong <[email protected]>
AuthorDate: Fri Aug 13 11:07:52 2021 +0800
feature : add integrated test for spring cloud plugin (#1891)
---
.github/workflows/integrated-test-spring-cloud.yml | 75 ++++++
shenyu-examples/shenyu-examples-eureka/Dockerfile | 29 +++
shenyu-examples/shenyu-examples-eureka/pom.xml | 33 +++
.../shenyu-examples-springcloud/Dockerfile | 29 +++
.../shenyu-examples-springcloud/pom.xml | 33 +++
shenyu-integrated-test/pom.xml | 1 +
.../shenyu-integrated-test-spring-cloud/Dockerfile | 29 +++
.../admin-config/schema.sql | 21 ++
.../docker-compose.yml | 115 ++++++++
.../shenyu-integrated-test-spring-cloud/pom.xml | 288 +++++++++++++++++++++
.../script/healthcheck.sh | 36 +++
.../script/services.list | 20 ++
.../springcloud/ShenyuBootstrapApplication.java | 38 +++
.../src/main/resources/application-local.yml | 73 ++++++
.../src/main/resources/application.yml | 18 ++
.../integratedtest/springcloud/AbstractTest.java | 34 +++
.../integratedtest/springcloud/HelloWorldTest.java | 37 +++
.../integratedtest/springcloud/dto/OrderDTO.java | 38 +++
.../integratedtest/springcloud/dto/UserDTO.java | 38 +++
.../springcloud/helper/HttpHelper.java | 113 ++++++++
20 files changed, 1098 insertions(+)
diff --git a/.github/workflows/integrated-test-spring-cloud.yml
b/.github/workflows/integrated-test-spring-cloud.yml
new file mode 100644
index 0000000..5bdbdd0
--- /dev/null
+++ b/.github/workflows/integrated-test-spring-cloud.yml
@@ -0,0 +1,75 @@
+# 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.
+
+name: integrated-test-spring-cloud
+
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+
+jobs:
+ build:
+ strategy:
+ matrix:
+# os: [ ubuntu-latest, macos-latest, windows-latest ]
+ os: [ ubuntu-latest ]
+ runs-on: ${{ matrix.os }}
+ steps:
+ - name: Support longpaths
+ if: ${{ matrix.os == 'windows-latest'}}
+ run: git config --system core.longpaths true
+ - uses: actions/checkout@v2
+ with:
+ submodules: true
+ - name: Set Skip Env Var
+ uses: ./.github/actions/skip-ci
+ - name: Cache Maven Repos
+ if: env.SKIP_CI != 'true'
+ uses: actions/cache@v2
+ with:
+ path: ~/.m2/repository
+ key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
+ restore-keys: |
+ ${{ runner.os }}-maven-
+ - uses: actions/setup-java@v1
+ if: env.SKIP_CI != 'true'
+ with:
+ java-version: 8
+ - name: Build with Maven
+ if: env.SKIP_CI != 'true'
+ run: ./mvnw -B clean install -Prelease,docker
-Dmaven.javadoc.skip=true -Dmaven.test.skip=true
+ - name: Build examples
+ if: env.SKIP_CI != 'true'
+ run: ./mvnw -B clean install -DskipTests -f
./shenyu-examples/shenyu-examples-springcloud/pom.xml
+ - name: Build eureka
+ if: env.SKIP_CI != 'true'
+ run: ./mvnw -B clean install -DskipTests -f
./shenyu-examples/shenyu-examples-eureka/pom.xml
+ - name: Build integrated tests
+ if: env.SKIP_CI != 'true'
+ run: ./mvnw -B clean install -DskipTests -f
./shenyu-integrated-test/shenyu-integrated-test-spring-cloud/pom.xml
+ - name: Start docker compose
+ if: env.SKIP_CI != 'true'
+ run: docker-compose -f
./shenyu-integrated-test/shenyu-integrated-test-spring-cloud/docker-compose.yml
up -d
+ - name: Wait for docker compose start up completely
+ if: env.SKIP_CI != 'true'
+ run: bash
./shenyu-integrated-test/shenyu-integrated-test-spring-cloud/script/healthcheck.sh
+ - name: Debug log
+ if: env.SKIP_CI != 'true'
+ run: cd ./shenyu-integrated-test/shenyu-integrated-test-spring-cloud;
docker-compose logs -t --tail="all" && cd ../../; cd ../../
+ - name: Run test
+ if: env.SKIP_CI != 'true'
+ run: ./mvnw test -f
./shenyu-integrated-test/shenyu-integrated-test-spring-cloud/pom.xml
diff --git a/shenyu-examples/shenyu-examples-eureka/Dockerfile
b/shenyu-examples/shenyu-examples-eureka/Dockerfile
new file mode 100644
index 0000000..339f694
--- /dev/null
+++ b/shenyu-examples/shenyu-examples-eureka/Dockerfile
@@ -0,0 +1,29 @@
+# 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.
+
+FROM java:openjdk-8-jre-alpine
+
+ENV APP_NAME shenyu-examples-eureka
+ENV LOCAL_PATH /opt/${APP_NAME}
+
+RUN mkdir -p ${LOCAL_PATH}
+
+ADD target/${APP_NAME}.jar ${LOCAL_PATH}
+
+WORKDIR ${LOCAL_PATH}
+EXPOSE 8761
+
+CMD java -jar ${APP_NAME}.jar
diff --git a/shenyu-examples/shenyu-examples-eureka/pom.xml
b/shenyu-examples/shenyu-examples-eureka/pom.xml
index b391e90..0be3a80 100644
--- a/shenyu-examples/shenyu-examples-eureka/pom.xml
+++ b/shenyu-examples/shenyu-examples-eureka/pom.xml
@@ -83,4 +83,37 @@
</dependency>
</dependencies>
+ <build>
+ <finalName>shenyu-examples-eureka</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <configuration>
+
<mainClass>org.apache.shenyu.examples.eureka.EurekaServerApplication</mainClass>
+ <executable>true</executable>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>com.spotify</groupId>
+ <artifactId>dockerfile-maven-plugin</artifactId>
+ <version>1.4.6</version>
+ <executions>
+ <execution>
+ <id>shenyu-examples-eureka</id>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <repository>shenyu-examples-eureka</repository>
+ <tag>latest</tag>
+ <buildArgs>
+ <APP_NAME>shenyu-examples-eureka</APP_NAME>
+ </buildArgs>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/shenyu-examples/shenyu-examples-springcloud/Dockerfile
b/shenyu-examples/shenyu-examples-springcloud/Dockerfile
new file mode 100644
index 0000000..14149ff
--- /dev/null
+++ b/shenyu-examples/shenyu-examples-springcloud/Dockerfile
@@ -0,0 +1,29 @@
+# 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.
+
+FROM java:openjdk-8-jre-alpine
+
+ENV APP_NAME shenyu-examples-springcloud
+ENV LOCAL_PATH /opt/${APP_NAME}
+
+RUN mkdir -p ${LOCAL_PATH}
+
+ADD target/${APP_NAME}.jar ${LOCAL_PATH}
+
+WORKDIR ${LOCAL_PATH}
+EXPOSE 8761
+
+CMD java -jar ${APP_NAME}.jar
diff --git a/shenyu-examples/shenyu-examples-springcloud/pom.xml
b/shenyu-examples/shenyu-examples-springcloud/pom.xml
index 2c45e3d..875bd99 100644
--- a/shenyu-examples/shenyu-examples-springcloud/pom.xml
+++ b/shenyu-examples/shenyu-examples-springcloud/pom.xml
@@ -70,4 +70,37 @@
<version>${spring-cloud.version}</version>
</dependency>
</dependencies>
+ <build>
+ <finalName>shenyu-examples-springcloud</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <configuration>
+
<mainClass>org.apache.shenyu.examples.springcloud.ShenyuTestSpringCloudApplication</mainClass>
+ <executable>true</executable>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>com.spotify</groupId>
+ <artifactId>dockerfile-maven-plugin</artifactId>
+ <version>1.4.6</version>
+ <executions>
+ <execution>
+ <id>shenyu-examples-springcloud</id>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <repository>shenyu-examples-springcloud</repository>
+ <tag>latest</tag>
+ <buildArgs>
+ <APP_NAME>shenyu-examples-springcloud</APP_NAME>
+ </buildArgs>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/shenyu-integrated-test/pom.xml b/shenyu-integrated-test/pom.xml
index 2dad364..018cf67 100644
--- a/shenyu-integrated-test/pom.xml
+++ b/shenyu-integrated-test/pom.xml
@@ -20,6 +20,7 @@
<modelVersion>4.0.0</modelVersion>
<modules>
<module>shenyu-integrated-test-http</module>
+ <module>shenyu-integrated-test-spring-cloud</module>
</modules>
<parent>
diff --git
a/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/Dockerfile
b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/Dockerfile
new file mode 100644
index 0000000..8d9b90e
--- /dev/null
+++ b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/Dockerfile
@@ -0,0 +1,29 @@
+# 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.
+
+FROM java:openjdk-8-jre-alpine
+
+ENV APP_NAME shenyu-integrated-test-spring-cloud
+ENV LOCAL_PATH /opt/${APP_NAME}
+
+RUN mkdir -p ${LOCAL_PATH}
+
+ADD target/${APP_NAME}.jar ${LOCAL_PATH}
+
+WORKDIR ${LOCAL_PATH}
+EXPOSE 9195
+
+CMD java -jar ${APP_NAME}.jar
diff --git
a/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/admin-config/schema.sql
b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/admin-config/schema.sql
new file mode 100644
index 0000000..c726528
--- /dev/null
+++
b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/admin-config/schema.sql
@@ -0,0 +1,21 @@
+-- noinspection SqlNoDataSourceInspectionForFile
+
+-- 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.
+
+/** prepare rate limit **/
+UPDATE `plugin` SET enabled = 1 WHERE id = '8';
+UPDATE `plugin` SET enabled = 0 WHERE id = '5';
\ No newline at end of file
diff --git
a/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/docker-compose.yml
b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/docker-compose.yml
new file mode 100644
index 0000000..54a850c
--- /dev/null
+++
b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/docker-compose.yml
@@ -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.
+version: "3.9"
+services:
+ shenyu-admin:
+ image: apache/shenyu-admin:2.4.0-SNAPSHOT
+ container_name: shenyu-admin
+ restart: always
+ networks:
+ - shenyu
+ volumes:
+ - type: bind
+ source: ./admin-config/
+ target: /opt/sql/
+ ports:
+ - 9095:9095
+ environment:
+ - SPRING_PROFILES_ACTIVE=h2
+ -
shenyu.database.init_script=META-INF/schema.h2.sql;file:/opt/sql/schema.sql
+ healthcheck:
+ test: [ "CMD", "wget", "-q", "-O", "-",
"http://localhost:9095/actuator/health" ]
+ timeout: 2s
+ retries: 3
+ start_period: 5s
+ shenyu-examples-eureka:
+ deploy:
+ resources:
+ limits:
+ memory: 2048M
+ container_name: shenyu-examples-eureka
+ image: shenyu-examples-eureka:latest
+ restart: always
+ healthcheck:
+ test: [ "CMD", "wget", "-q", "-O", "-", "http://localhost:8761" ]
+ timeout: 2s
+ retries: 3
+ start_period: 5s
+ ports:
+ - 8761:8761
+ networks:
+ - shenyu
+ depends_on:
+ shenyu-admin:
+ condition: service_healthy
+ shenyu-examples-springcloud:
+ deploy:
+ resources:
+ limits:
+ memory: 2048M
+ container_name: shenyu-examples-springcloud
+ image: shenyu-examples-springcloud:latest
+ restart: always
+ environment:
+ - shenyu.client.serverLists=http://shenyu-admin:9095
+ -
eureka.client.serviceUrl.defaultZone=http://shenyu-examples-eureka:8761/eureka/
+ healthcheck:
+ test: [ "CMD", "wget", "-q", "-O", "-",
"http://localhost:8884/test/findByUserId?userId=tom" ]
+ timeout: 2s
+ retries: 3
+ start_period: 5s
+ ports:
+ - 8884:8884
+ networks:
+ - shenyu
+ depends_on:
+ shenyu-examples-eureka:
+ condition: service_healthy
+ # from http plugin dockerfile
+ shenyu-integrated-test-spring-cloud:
+ container_name: shenyu-integrated-test-spring-cloud
+ image: apache/shenyu-integrated-test-spring-cloud:latest
+ restart: always
+ deploy:
+ resources:
+ limits:
+ memory: 2048M
+ environment:
+ - shenyu.sync.websocket.urls=ws://shenyu-admin:9095/websocket
+ -
eureka.client.serviceUrl.defaultZone=http://shenyu-examples-eureka:8761/eureka/
+ depends_on:
+ - shenyu-examples-springcloud
+ - shenyu-admin
+ ports:
+ - 9195:9195
+ healthcheck:
+ test: [ "CMD", "wget", "-q", "-O", "-",
"http://localhost:9195/springcloud/test/findByUserId?userId=Tom" ]
+ timeout: 2s
+ retries: 3
+ start_period: 5s
+ networks:
+ - shenyu
+ health-checker:
+ container_name: health-checker
+ image: hello-world
+ restart: always
+ depends_on:
+ shenyu-integrated-test-spring-cloud:
+ condition: service_healthy
+
+networks:
+ shenyu:
+ name: shenyu
diff --git a/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/pom.xml
b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/pom.xml
new file mode 100644
index 0000000..8a772b9
--- /dev/null
+++ b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/pom.xml
@@ -0,0 +1,288 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+<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">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>shenyu-integrated-test</artifactId>
+ <groupId>org.apache.shenyu</groupId>
+ <version>2.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>shenyu-integrated-test-spring-cloud</artifactId>
+ <version>2.4.0-SNAPSHOT</version>
+ <!-- <packaging>jar</packaging>-->
+
+ <name>shenyu-integrated-test-http</name>
+ <!-- FIXME change it to the project's website -->
+ <url>https://shenyu.apache.org</url>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ <spring-cloud.version>2.2.0.RELEASE</spring-cloud.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-webflux</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-actuator</artifactId>
+ </dependency>
+
+ <!--shenyu gateway start-->
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-spring-boot-starter-gateway</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- shenyu waf plugin starter-->
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-spring-boot-starter-plugin-waf</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!-- shenyu waf plugin end-->
+
+ <!-- shenyu monitor plugin starter-->
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-spring-boot-starter-plugin-monitor</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!-- shenyu monitor plugin end-->
+
+ <!-- shenyu sign plugin start-->
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-spring-boot-starter-plugin-sign</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!-- shenyu sign plugin end-->
+
+ <!-- shenyu sentinel plugin start-->
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-spring-boot-starter-plugin-sentinel</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!-- shenyu sentinel plugin end-->
+
+ <!-- shenyu redirect plugin start-->
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-spring-boot-starter-plugin-redirect</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!-- shenyu redirect plugin end-->
+
+ <!-- shenyu redirect plugin start-->
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-spring-boot-starter-plugin-rewrite</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!-- shenyu redirect plugin end-->
+
+ <!--shenyu debug plugin start-->
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-spring-boot-starter-plugin-logging</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!--shenyu debug plugin end-->
+
+ <!--shenyu tars plugin start-->
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-spring-boot-starter-plugin-tars</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.tencent.tars</groupId>
+ <artifactId>tars-client</artifactId>
+ <version>1.7.2</version>
+ </dependency>
+ <!--shenyu tars plugin end-->
+
+ <!--shenyu grpc plugin start-->
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-spring-boot-starter-plugin-grpc</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!--shenyu grpc plugin end-->
+
+ <!--shenyu sofa plugin start-->
+ <dependency>
+ <groupId>com.alipay.sofa</groupId>
+ <artifactId>sofa-rpc-all</artifactId>
+ <version>5.7.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-spring-boot-starter-plugin-sofa</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!--shenyu sofa plugin end-->
+
+ <!--shenyu springCloud plugin start-->
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+
<artifactId>shenyu-spring-boot-starter-plugin-springcloud</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-commons</artifactId>
+ <version>2.2.0.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
+ <version>${spring-cloud.version}</version>
+ </dependency>
+ <!--shenyu springCloud plugin start end-->
+
+ <!--shenyu data sync start use zookeeper-->
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+
<artifactId>shenyu-spring-boot-starter-sync-data-zookeeper</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!--shenyu data sync start use websocket-->
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+
<artifactId>shenyu-spring-boot-starter-sync-data-websocket</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!--shenyu data sync start use http-->
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-spring-boot-starter-sync-data-http</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!--shenyu data sync start use etcd-->
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-spring-boot-starter-sync-data-etcd</artifactId>
+ <version>${project.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-grpclb</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-netty</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <!--shenyu debug plugin end-->
+
+ <!-- shenyu modify response plugin start-->
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+
<artifactId>shenyu-spring-boot-starter-plugin-modify-response</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!-- shenyu modify response plugin end-->
+
+ <!-- shenyu response plugin start-->
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-spring-boot-starter-plugin-response</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!-- shenyu response plugin end-->
+
+ <!--shenyu request plugin start-->
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-spring-boot-starter-plugin-request</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!--shenyu request plugin end-->
+
+ <!--shenyu param mapping plugin start-->
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+
<artifactId>shenyu-spring-boot-starter-plugin-param-mapping</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!--shenyu param mapping end-->
+ </dependencies>
+
+ <build>
+ <finalName>shenyu-integrated-test-spring-cloud</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <version>${spring-boot.version}</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+
<mainClass>org.apache.shenyu.integratedtest.springcloud.ShenyuBootstrapApplication</mainClass>
+ <executable>true</executable>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>com.spotify</groupId>
+ <artifactId>dockerfile-maven-plugin</artifactId>
+ <version>1.4.6</version>
+ <executions>
+ <execution>
+ <id>shenyu-integrated-test-spring-cloud</id>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+
<repository>apache/shenyu-integrated-test-spring-cloud</repository>
+ <tag>latest</tag>
+ <buildArgs>
+
<APP_NAME>shenyu-integrated-test-spring-cloud</APP_NAME>
+ </buildArgs>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
diff --git
a/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/script/healthcheck.sh
b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/script/healthcheck.sh
new file mode 100644
index 0000000..d181f7e
--- /dev/null
+++
b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/script/healthcheck.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# 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.
+#
+
+PRGDIR=`dirname "$0"`
+# Waiting for service registration
+sleep 30s
+for service in `grep -v -E "^$|^#" ${PRGDIR}/services.list`
+do
+ for loop in `seq 1 30`
+ do
+ status=`curl -o /dev/null -s -w %{http_code} $service`
+ echo -e "curl $service response $status"
+ if [ $status -eq 200 ]; then
+ break
+ fi
+
+ sleep 2
+ done
+done
+sleep 3s
+echo -e "\n-------------------"
diff --git
a/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/script/services.list
b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/script/services.list
new file mode 100644
index 0000000..ca07692
--- /dev/null
+++
b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/script/services.list
@@ -0,0 +1,20 @@
+# 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.
+
+http://localhost:9095/actuator/health
+http://localhost:8761
+http://localhost:8884/test/findByUserId?userId=tom
+http://localhost:9195/springcloud/test/findByUserId?userId=Tom
diff --git
a/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/src/main/java/org/apache/shenyu/integratedtest/springcloud/ShenyuBootstrapApplication.java
b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/src/main/java/org/apache/shenyu/integratedtest/springcloud/ShenyuBootstrapApplication.java
new file mode 100644
index 0000000..dd475fc
--- /dev/null
+++
b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/src/main/java/org/apache/shenyu/integratedtest/springcloud/ShenyuBootstrapApplication.java
@@ -0,0 +1,38 @@
+/*
+ * 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.integratedtest.springcloud;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+
+/**
+ * Hello world.
+ */
+@SpringBootApplication
+@EnableDiscoveryClient
+public class ShenyuBootstrapApplication {
+ /**
+ * main method of App.
+ *
+ * @param args args
+ */
+ public static void main(final String[] args) {
+ SpringApplication.run(ShenyuBootstrapApplication.class);
+ }
+}
diff --git
a/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/src/main/resources/application-local.yml
b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/src/main/resources/application-local.yml
new file mode 100644
index 0000000..d75206c
--- /dev/null
+++
b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/src/main/resources/application-local.yml
@@ -0,0 +1,73 @@
+# 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.
+
+server:
+ port: 9195
+ address: 0.0.0.0
+
+spring:
+ main:
+ allow-bean-definition-overriding: true
+ application:
+ name: shenyu-bootstrap
+# cloud:
+# nacos:
+# discovery:
+# server-addr: 127.0.0.1:8848
+
+management:
+ health:
+ defaults:
+ enabled: false
+
+shenyu:
+ file:
+ enabled: true
+ cross:
+ enabled: true
+ dubbo:
+ parameter: multi
+ sync:
+ websocket:
+ urls: ws://localhost:9095/websocket
+ # zookeeper:
+ # url: localhost:2181
+ # sessionTimeout: 5000
+ # connectionTimeout: 2000
+ # http:
+ # url : http://localhost:9095
+
+ exclude:
+ enabled: false
+ paths:
+ - /favicon.ico
+
+eureka:
+ client:
+ serviceUrl:
+ defaultZone: http://localhost:8761/eureka/
+ instance:
+ prefer-ip-address: true
+
+
+logging:
+ level:
+ root: info
+ org.springframework.boot: info
+ org.apache.ibatis: info
+ org.apache.shenyu.bonuspoint: info
+ org.apache.shenyu.lottery: info
+ org.apache.shenyu: info
+
diff --git
a/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/src/main/resources/application.yml
b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/src/main/resources/application.yml
new file mode 100644
index 0000000..393ad24
--- /dev/null
+++
b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/src/main/resources/application.yml
@@ -0,0 +1,18 @@
+# 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.
+
+spring:
+ profiles:
+ active: local
diff --git
a/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/src/test/java/org/apache/shenyu/integratedtest/springcloud/AbstractTest.java
b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/src/test/java/org/apache/shenyu/integratedtest/springcloud/AbstractTest.java
new file mode 100644
index 0000000..511a202
--- /dev/null
+++
b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/src/test/java/org/apache/shenyu/integratedtest/springcloud/AbstractTest.java
@@ -0,0 +1,34 @@
+/*
+ * 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.integratedtest.springcloud;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * all tests must extend this class
+ * we will do something here. For example, update DB to init the data
+ */
+public class AbstractTest {
+
+ private static final ExecutorService SERVICE =
Executors.newCachedThreadPool();
+
+ protected ExecutorService getService() {
+ return SERVICE;
+ }
+}
diff --git
a/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/src/test/java/org/apache/shenyu/integratedtest/springcloud/HelloWorldTest.java
b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/src/test/java/org/apache/shenyu/integratedtest/springcloud/HelloWorldTest.java
new file mode 100644
index 0000000..88a201b
--- /dev/null
+++
b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/src/test/java/org/apache/shenyu/integratedtest/springcloud/HelloWorldTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.integratedtest.springcloud;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.shenyu.integratedtest.springcloud.dto.OrderDTO;
+import org.apache.shenyu.integratedtest.springcloud.helper.HttpHelper;
+import org.junit.Test;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class HelloWorldTest extends AbstractTest {
+
+ @Test
+ public void testHelloWorld() throws Exception {
+ OrderDTO order = new OrderDTO("123", "Phoenix");
+ order = HttpHelper.INSTANCE.postGateway("/springcloud/order/save",
order, OrderDTO.class);
+ assertEquals("hello world spring cloud save order", order.getName());
+ }
+}
diff --git
a/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/src/test/java/org/apache/shenyu/integratedtest/springcloud/dto/OrderDTO.java
b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/src/test/java/org/apache/shenyu/integratedtest/springcloud/dto/OrderDTO.java
new file mode 100644
index 0000000..d20a90a
--- /dev/null
+++
b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/src/test/java/org/apache/shenyu/integratedtest/springcloud/dto/OrderDTO.java
@@ -0,0 +1,38 @@
+/*
+ * 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.integratedtest.springcloud.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * The type Order dto.
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class OrderDTO implements Serializable {
+
+ private String id;
+
+ private String name;
+
+}
diff --git
a/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/src/test/java/org/apache/shenyu/integratedtest/springcloud/dto/UserDTO.java
b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/src/test/java/org/apache/shenyu/integratedtest/springcloud/dto/UserDTO.java
new file mode 100644
index 0000000..3b735b7
--- /dev/null
+++
b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/src/test/java/org/apache/shenyu/integratedtest/springcloud/dto/UserDTO.java
@@ -0,0 +1,38 @@
+/*
+ * 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.integratedtest.springcloud.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * The type Order dto.
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class UserDTO implements Serializable {
+
+ private String userId;
+
+ private String userName;
+
+}
diff --git
a/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/src/test/java/org/apache/shenyu/integratedtest/springcloud/helper/HttpHelper.java
b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/src/test/java/org/apache/shenyu/integratedtest/springcloud/helper/HttpHelper.java
new file mode 100644
index 0000000..2c34595
--- /dev/null
+++
b/shenyu-integrated-test/shenyu-integrated-test-spring-cloud/src/test/java/org/apache/shenyu/integratedtest/springcloud/helper/HttpHelper.java
@@ -0,0 +1,113 @@
+/*
+ * 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.integratedtest.springcloud.helper;
+
+import java.io.IOException;
+import java.lang.reflect.Type;
+import java.util.Map;
+
+import org.springframework.util.CollectionUtils;
+
+import com.google.gson.Gson;
+
+import lombok.extern.slf4j.Slf4j;
+import okhttp3.MediaType;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+import okhttp3.Response;
+
+@Slf4j
+public class HttpHelper {
+
+ public static final HttpHelper INSTANCE = new HttpHelper();
+
+ public static final String GATEWAY_END_POINT = "http://localhost:9195";
+
+ public static final MediaType JSON = MediaType.parse("application/json");
+
+ private static final Gson GSON = new Gson();
+
+ private final OkHttpClient client = new OkHttpClient.Builder().build();
+
+ /**
+ * Send a post http request to shenyu gateway.
+ *
+ * @param path path
+ * @param req request body as an object
+ * @param respType response type passed to {@link Gson#fromJson(String,
Class)}
+ * @param <S> type of response object
+ * @param <Q> type of request object
+ * @return response
+ * @throws IOException IO exception
+ */
+ public <S, Q> S postGateway(final String path, final Q req, final Class<S>
respType) throws IOException {
+ Request request = new Request.Builder()
+ .url(GATEWAY_END_POINT + path)
+ .post(RequestBody.create(GSON.toJson(req), JSON))
+ .build();
+ Response response = client.newCall(request).execute();
+ String respBody = response.body().string();
+ log.info("postGateway({}) resp({})", path, respBody);
+ return GSON.fromJson(respBody, respType);
+ }
+
+ /**
+ * Send a get http request to shenyu gateway without headers.
+ *
+ * @param path path
+ * @param type type of response passed to {@link Gson#fromJson(String,
Type)}
+ * @param <S> response type
+ * @return response
+ * @throws IOException IO exception
+ */
+ public <S> S getFromGateway(final String path, final Type type) throws
IOException {
+ return this.getFromGateway(path, null, type);
+ }
+
+ /**
+ * Send a get http request to shenyu gateway with headers.
+ *
+ * @param path path
+ * @param headers headers
+ * @param type type of response passed to {@link Gson#fromJson(String,
Type)}
+ * @param <S> response type
+ * @return response
+ * @throws IOException IO exception
+ */
+ public <S> S getFromGateway(final String path, final Map<String, Object>
headers, final Type type) throws IOException {
+ Request.Builder requestBuilder = new
Request.Builder().url(GATEWAY_END_POINT + path);
+ if (!CollectionUtils.isEmpty(headers)) {
+ headers.forEach((key, value) -> requestBuilder.addHeader(key,
String.valueOf(value)));
+ }
+ Request request = requestBuilder.build();
+ Response response = client.newCall(request).execute();
+ String respBody = response.body().string();
+ log.info("getFromGateway({}) resp({})", path, respBody);
+ return GSON.fromJson(respBody, type);
+ }
+
+ /**
+ * get client.
+ *
+ * @return client
+ */
+ public OkHttpClient getClient() {
+ return this.client;
+ }
+}