You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by zh...@apache.org on 2022/06/12 05:06:35 UTC

[incubator-shenyu] branch master updated: Add integration test in shenyu-integrated-test-alibaba-dubbo (#3536)

This is an automated email from the ASF dual-hosted git repository.

zhangzicheng 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 3671086de Add integration test in shenyu-integrated-test-alibaba-dubbo (#3536)
3671086de is described below

commit 3671086de0da37b302702c88e3917eaee2658155
Author: renzhuyan <40...@qq.com>
AuthorDate: Sun Jun 12 00:06:28 2022 -0500

    Add integration test in shenyu-integrated-test-alibaba-dubbo (#3536)
---
 .../src/main/resources/application-local.yml       |  3 +-
 .../AlibabaDubboPluginSharedThreadPoolTest.java    | 73 ++++++++++++++++++++++
 2 files changed, 75 insertions(+), 1 deletion(-)

diff --git a/shenyu-integrated-test/shenyu-integrated-test-alibaba-dubbo/src/main/resources/application-local.yml b/shenyu-integrated-test/shenyu-integrated-test-alibaba-dubbo/src/main/resources/application-local.yml
index 8666f83ec..4a775e25c 100644
--- a/shenyu-integrated-test/shenyu-integrated-test-alibaba-dubbo/src/main/resources/application-local.yml
+++ b/shenyu-integrated-test/shenyu-integrated-test-alibaba-dubbo/src/main/resources/application-local.yml
@@ -48,7 +48,8 @@ shenyu:
   local:
     enabled: true
     sha512Key: "BA3253876AED6BC22D4A6FF53D8406C6AD864195ED144AB5C87621B6C233B548BAEAE6956DF346EC8C17F5EA10F35EE3CBC514797ED7DDD3145464E2A0BAB413"
-
+  sharedPool:
+    enable: true
 logging:
   level:
     root: info
diff --git a/shenyu-integrated-test/shenyu-integrated-test-alibaba-dubbo/src/test/java/org/apache/shenyu/integrated/test/alibaba/dubbo/AlibabaDubboPluginSharedThreadPoolTest.java b/shenyu-integrated-test/shenyu-integrated-test-alibaba-dubbo/src/test/java/org/apache/shenyu/integrated/test/alibaba/dubbo/AlibabaDubboPluginSharedThreadPoolTest.java
new file mode 100644
index 000000000..1d9027862
--- /dev/null
+++ b/shenyu-integrated-test/shenyu-integrated-test-alibaba-dubbo/src/test/java/org/apache/shenyu/integrated/test/alibaba/dubbo/AlibabaDubboPluginSharedThreadPoolTest.java
@@ -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.
+ */
+
+package org.apache.shenyu.integrated.test.alibaba.dubbo;
+
+import com.google.gson.reflect.TypeToken;
+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.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.util.List;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class AlibabaDubboPluginSharedThreadPoolTest extends AbstractPluginDataInit {
+
+    @BeforeAll
+    public static void setup() throws IOException {
+        String pluginResult = initPlugin(PluginEnum.DUBBO.getName(), "{\"register\":\"zookeeper://shenyu-zk:2181\",\"threadpool\": \"shared\"}");
+        assertThat(pluginResult, is("success"));
+    }
+
+    @Test
+    public void testFindById() throws IOException {
+        DubboTest dubboTest = HttpHelper.INSTANCE.getFromGateway("/dubbo/findById?id=1", new TypeToken<DubboTest>() {
+        }.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());
+    }
+}