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 fe6f340 1. add integrated test for DubboTestService in
shenyu-examples-apache-dubbo-service (#2741)
fe6f340 is described below
commit fe6f3402888c7f2795c80f7b3ca5b251cab99f6b
Author: AhahaGe <[email protected]>
AuthorDate: Mon Jan 10 16:40:58 2022 +0800
1. add integrated test for DubboTestService in
shenyu-examples-apache-dubbo-service (#2741)
2. add integrated test for DubboTestService in
shenyu-examples-alibaba-dubbo-service
---
.../common/dto/IdArrayAndNameRequest.java | 72 ++++++++++++++++++++
.../common/dto/IdsAndNameRequest.java | 74 +++++++++++++++++++++
.../shenyu/integratedtest/common/dto/ListResp.java | 77 ++++++++++++++++++++++
.../alibaba/dubbo/AlibabaDubboPluginTest.java | 28 +++++++-
.../alibaba/dubbo/ApacheDubboPluginTest.java | 33 ++++++++--
5 files changed, 277 insertions(+), 7 deletions(-)
diff --git
a/shenyu-integrated-test/shenyu-integrated-test-common/src/main/java/org/apache/shenyu/integratedtest/common/dto/IdArrayAndNameRequest.java
b/shenyu-integrated-test/shenyu-integrated-test-common/src/main/java/org/apache/shenyu/integratedtest/common/dto/IdArrayAndNameRequest.java
new file mode 100644
index 0000000..8240725
--- /dev/null
+++
b/shenyu-integrated-test/shenyu-integrated-test-common/src/main/java/org/apache/shenyu/integratedtest/common/dto/IdArrayAndNameRequest.java
@@ -0,0 +1,72 @@
+/*
+ * 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.common.dto;
+
+/**
+ * Request object contains id array and name property.
+ */
+public class IdArrayAndNameRequest {
+ /**
+ * Request param id array.
+ */
+ private Integer[] ids;
+
+ /**
+ * Request param name.
+ */
+ private String name;
+
+ public IdArrayAndNameRequest() { }
+
+ public IdArrayAndNameRequest(final Integer[] ids, final String name) {
+ this.ids = ids;
+ this.name = name;
+ }
+
+ /**
+ * Get request param name.
+ * @return name Request param name.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Set request param name.
+ * @param name Request param name.
+ */
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ /**
+ * Return request param id list.
+ * @return ids Request param id list.
+ */
+ public Integer[] getIds() {
+ return ids;
+ }
+
+ /**
+ * Set request param id list.
+ * @param ids Request param id list.
+ */
+ public void setIds(final Integer[] ids) {
+ this.ids = ids;
+ }
+}
diff --git
a/shenyu-integrated-test/shenyu-integrated-test-common/src/main/java/org/apache/shenyu/integratedtest/common/dto/IdsAndNameRequest.java
b/shenyu-integrated-test/shenyu-integrated-test-common/src/main/java/org/apache/shenyu/integratedtest/common/dto/IdsAndNameRequest.java
new file mode 100644
index 0000000..7b0a0a5
--- /dev/null
+++
b/shenyu-integrated-test/shenyu-integrated-test-common/src/main/java/org/apache/shenyu/integratedtest/common/dto/IdsAndNameRequest.java
@@ -0,0 +1,74 @@
+/*
+ * 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.common.dto;
+
+import java.util.List;
+
+/**
+ * Request object contains id list and name property.
+ */
+public class IdsAndNameRequest {
+ /**
+ * Request param id list.
+ */
+ private List<Integer> ids;
+
+ /**
+ * Request param name.
+ */
+ private String name;
+
+ public IdsAndNameRequest() { }
+
+ public IdsAndNameRequest(final List<Integer> ids, final String name) {
+ this.ids = ids;
+ this.name = name;
+ }
+
+ /**
+ * Return request param id list.
+ * @return ids Request param id list.
+ */
+ public List<Integer> getIds() {
+ return ids;
+ }
+
+ /**
+ * Set request param id list.
+ * @param ids Request param id list.
+ */
+ public void setIds(final List<Integer> ids) {
+ this.ids = ids;
+ }
+
+ /**
+ * Get request param name.
+ * @return name Request param name.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Set request param name.
+ * @param name Request param name.
+ */
+ public void setName(final String name) {
+ this.name = name;
+ }
+}
diff --git
a/shenyu-integrated-test/shenyu-integrated-test-common/src/main/java/org/apache/shenyu/integratedtest/common/dto/ListResp.java
b/shenyu-integrated-test/shenyu-integrated-test-common/src/main/java/org/apache/shenyu/integratedtest/common/dto/ListResp.java
new file mode 100644
index 0000000..7c68c5f
--- /dev/null
+++
b/shenyu-integrated-test/shenyu-integrated-test-common/src/main/java/org/apache/shenyu/integratedtest/common/dto/ListResp.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.integratedtest.common.dto;
+
+import java.util.List;
+
+public class ListResp {
+
+ private Integer total;
+
+ private List<DubboTest> users;
+
+ public ListResp() {
+ }
+
+ public ListResp(final Integer total, final List<DubboTest> users) {
+ this.total = total;
+ this.users = users;
+ }
+
+ /**
+ * Get total.
+ *
+ * @return total
+ */
+ public Integer getTotal() {
+ return total;
+ }
+
+ /**
+ * Set total.
+ *
+ * @param total total
+ */
+ public void setTotal(final Integer total) {
+ this.total = total;
+ }
+
+ /**
+ * Get users.
+ *
+ * @return users
+ */
+ public List<DubboTest> getUsers() {
+ return users;
+ }
+
+ /**
+ * Set users.
+ *
+ * @param users users
+ */
+ public void setUsers(final List<DubboTest> users) {
+ this.users = users;
+ }
+
+ @Override
+ public String toString() {
+ return "ListResp{" + "total=" + total + ", users=" + users + '}';
+ }
+
+}
diff --git
a/shenyu-integrated-test/shenyu-integration-test-alibaba-dubbo/src/test/java/org/apache/shenyu/integratedtest/alibaba/dubbo/AlibabaDubboPluginTest.java
b/shenyu-integrated-test/shenyu-integration-test-alibaba-dubbo/src/test/java/org/apache/shenyu/integratedtest/alibaba/dubbo/AlibabaDubboPluginTest.java
index d27469e..46960da 100644
---
a/shenyu-integrated-test/shenyu-integration-test-alibaba-dubbo/src/test/java/org/apache/shenyu/integratedtest/alibaba/dubbo/AlibabaDubboPluginTest.java
+++
b/shenyu-integrated-test/shenyu-integration-test-alibaba-dubbo/src/test/java/org/apache/shenyu/integratedtest/alibaba/dubbo/AlibabaDubboPluginTest.java
@@ -18,15 +18,16 @@
package org.apache.shenyu.integratedtest.alibaba.dubbo;
import com.google.gson.reflect.TypeToken;
+import java.io.IOException;
+import java.util.List;
import org.apache.shenyu.common.enums.PluginEnum;
import org.apache.shenyu.integratedtest.common.AbstractPluginDataInit;
import org.apache.shenyu.integratedtest.common.dto.DubboTest;
+import org.apache.shenyu.integratedtest.common.dto.ListResp;
import org.apache.shenyu.integratedtest.common.helper.HttpHelper;
import org.junit.BeforeClass;
import org.junit.Test;
-import java.io.IOException;
-
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
@@ -45,4 +46,27 @@ public class AlibabaDubboPluginTest extends
AbstractPluginDataInit {
}.getType());
assertEquals("hello world shenyu Alibaba Dubbo, findById",
dubboTest.getName());
}
+
+ @Test
+ public void testFindAll() throws IOException {
+ DubboTest dubboTest =
HttpHelper.INSTANCE.getFromGateway("/dubbo/findAll", DubboTest.class);
+ assertEquals("hello world shenyu Alibaba Dubbo , findAll",
dubboTest.getName());
+ }
+
+ @Test
+ public void testInsert() throws IOException {
+ DubboTest req = new DubboTest("1", "insertName");
+ DubboTest dubboTest = HttpHelper.INSTANCE.postGateway("/dubbo/insert",
req, DubboTest.class);
+ assertEquals("hello world shenyu Alibaba Dubbo: insertName",
dubboTest.getName());
+ assertEquals("1", dubboTest.getId());
+ }
+
+ @Test
+ public void testFindList() throws IOException {
+ ListResp listResp =
HttpHelper.INSTANCE.getFromGateway("/dubbo/findList", ListResp.class);
+ List<DubboTest> users = listResp.getUsers();
+ assertEquals(listResp.getTotal().intValue(), users.size());
+ assertEquals("test", users.get(0).getName());
+ assertEquals("1", users.get(0).getId());
+ }
}
diff --git
a/shenyu-integrated-test/shenyu-integration-test-apache-dubbo/src/test/java/org/apache/shenyu/integratedtest/alibaba/dubbo/ApacheDubboPluginTest.java
b/shenyu-integrated-test/shenyu-integration-test-apache-dubbo/src/test/java/org/apache/shenyu/integratedtest/alibaba/dubbo/ApacheDubboPluginTest.java
index 81aa076..83a88a9 100644
---
a/shenyu-integrated-test/shenyu-integration-test-apache-dubbo/src/test/java/org/apache/shenyu/integratedtest/alibaba/dubbo/ApacheDubboPluginTest.java
+++
b/shenyu-integrated-test/shenyu-integration-test-apache-dubbo/src/test/java/org/apache/shenyu/integratedtest/alibaba/dubbo/ApacheDubboPluginTest.java
@@ -17,16 +17,16 @@
package org.apache.shenyu.integratedtest.alibaba.dubbo;
-import com.google.gson.reflect.TypeToken;
+import java.io.IOException;
+import java.util.List;
import org.apache.shenyu.common.enums.PluginEnum;
import org.apache.shenyu.integratedtest.common.AbstractPluginDataInit;
import org.apache.shenyu.integratedtest.common.dto.DubboTest;
+import org.apache.shenyu.integratedtest.common.dto.ListResp;
import org.apache.shenyu.integratedtest.common.helper.HttpHelper;
import org.junit.BeforeClass;
import org.junit.Test;
-import java.io.IOException;
-
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
@@ -41,8 +41,31 @@ public class ApacheDubboPluginTest extends
AbstractPluginDataInit {
@Test
public void testFindById() throws IOException {
- DubboTest dubboTest =
HttpHelper.INSTANCE.getFromGateway("/dubbo/findById?id=1", new
TypeToken<DubboTest>() {
- }.getType());
+ DubboTest dubboTest =
HttpHelper.INSTANCE.getFromGateway("/dubbo/findById?id=1", DubboTest.class);
assertEquals("hello world shenyu Apache, findById",
dubboTest.getName());
+ assertEquals("1", dubboTest.getId());
+ }
+
+ @Test
+ public void testFindAll() throws IOException {
+ DubboTest dubboTest =
HttpHelper.INSTANCE.getFromGateway("/dubbo/findAll", DubboTest.class);
+ assertEquals("hello world shenyu Apache, findAll",
dubboTest.getName());
+ }
+
+ @Test
+ public void testInsert() throws IOException {
+ DubboTest req = new DubboTest("1", "insertName");
+ DubboTest dubboTest = HttpHelper.INSTANCE.postGateway("/dubbo/insert",
req, DubboTest.class);
+ assertEquals("hello world shenyu Apache Dubbo: insertName",
dubboTest.getName());
+ assertEquals("1", dubboTest.getId());
+ }
+
+ @Test
+ public void testFindList() throws IOException {
+ ListResp listResp =
HttpHelper.INSTANCE.getFromGateway("/dubbo/findList", ListResp.class);
+ List<DubboTest> users = listResp.getUsers();
+ assertEquals(listResp.getTotal().intValue(), users.size());
+ assertEquals("test", users.get(0).getName());
+ assertEquals("1", users.get(0).getId());
}
}