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/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new a026635f30 test client grpc test case (#5395)
a026635f30 is described below
commit a026635f30d159a1814811b99074998eaa01c136
Author: zhengke zhou <[email protected]>
AuthorDate: Fri Jan 26 16:42:18 2024 +0800
test client grpc test case (#5395)
* test client grpc test case
* fix format
---------
Co-authored-by: dragon-zhang <[email protected]>
Co-authored-by: moremind <[email protected]>
---
.../org/apache/shenyu/client/grpc/TestRequest.java | 29 ++++++++++++++++
.../apache/shenyu/client/grpc/TestResponse.java | 29 ++++++++++++++++
.../grpc/json/JsonForwardingServerCallTest.java | 33 ++++++++++++++++++
.../grpc/json/JsonServerCallListenerTest.java | 33 ++++++++++++++++++
.../json/JsonServerServiceInterceptorTest.java | 22 ++++++++++++
.../client/grpc/server/GrpcServerRunnerTest.java | 40 ++++++++++++++++++++++
6 files changed, 186 insertions(+)
diff --git
a/shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/TestRequest.java
b/shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/TestRequest.java
new file mode 100644
index 0000000000..58f6db248b
--- /dev/null
+++
b/shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/TestRequest.java
@@ -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.
+ */
+
+package org.apache.shenyu.client.grpc;
+
+/**
+ * name request message.
+ */
+public class TestRequest {
+ private final String name;
+
+ public TestRequest(final String name) {
+ this.name = name;
+ }
+}
diff --git
a/shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/TestResponse.java
b/shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/TestResponse.java
new file mode 100644
index 0000000000..b9f31e0a05
--- /dev/null
+++
b/shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/TestResponse.java
@@ -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.
+ */
+
+package org.apache.shenyu.client.grpc;
+
+/**
+ * name response message.
+ */
+public class TestResponse {
+ private final String name;
+
+ public TestResponse(final String name) {
+ this.name = name;
+ }
+}
diff --git
a/shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/json/JsonForwardingServerCallTest.java
b/shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/json/JsonForwardingServerCallTest.java
new file mode 100644
index 0000000000..98fc74aee3
--- /dev/null
+++
b/shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/json/JsonForwardingServerCallTest.java
@@ -0,0 +1,33 @@
+/*
+ * 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.client.grpc.json;
+
+import org.apache.shenyu.client.grpc.TestRequest;
+import org.apache.shenyu.client.grpc.TestResponse;
+import org.junit.jupiter.api.Test;
+
+import static org.mockito.Mockito.mock;
+
+public class JsonForwardingServerCallTest {
+ private final JsonForwardingServerCall<TestRequest, TestResponse>
testJsonForwardingServerCall = mock(JsonForwardingServerCall.class);
+
+ @Test
+ public void sentMsgTest() {
+ testJsonForwardingServerCall.sendMessage(new
TestResponse("test-response"));
+ }
+}
diff --git
a/shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/json/JsonServerCallListenerTest.java
b/shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/json/JsonServerCallListenerTest.java
new file mode 100644
index 0000000000..3e70c5cd69
--- /dev/null
+++
b/shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/json/JsonServerCallListenerTest.java
@@ -0,0 +1,33 @@
+/*
+ * 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.client.grpc.json;
+
+import org.apache.shenyu.client.grpc.TestRequest;
+import org.apache.shenyu.client.grpc.TestResponse;
+import org.junit.jupiter.api.Test;
+
+import static org.mockito.Mockito.mock;
+
+public class JsonServerCallListenerTest {
+ private final JsonServerCallListener<TestRequest, TestResponse>
testJsonServerCallListener = mock(JsonServerCallListener.class);
+
+ @Test
+ public void testOnMessage() {
+ testJsonServerCallListener.onMessage(new
TestRequest("test-on-message"));
+ }
+}
diff --git
a/shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/json/JsonServerServiceInterceptorTest.java
b/shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/json/JsonServerServiceInterceptorTest.java
new file mode 100644
index 0000000000..d523feaec3
--- /dev/null
+++
b/shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/json/JsonServerServiceInterceptorTest.java
@@ -0,0 +1,22 @@
+/*
+ * 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.client.grpc.json;
+
+public class JsonServerServiceInterceptorTest {
+
+}
diff --git
a/shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/server/GrpcServerRunnerTest.java
b/shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/server/GrpcServerRunnerTest.java
new file mode 100644
index 0000000000..050cd2a179
--- /dev/null
+++
b/shenyu-client/shenyu-client-grpc/src/test/java/org/apache/shenyu/client/grpc/server/GrpcServerRunnerTest.java
@@ -0,0 +1,40 @@
+/*
+ * 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.client.grpc.server;
+
+import io.grpc.ServerBuilder;
+import org.apache.shenyu.client.grpc.GrpcClientEventListener;
+import org.junit.jupiter.api.Test;
+import org.springframework.context.event.ContextRefreshedEvent;
+
+import static org.mockito.Mockito.mock;
+
+public class GrpcServerRunnerTest {
+ private final ContextRefreshedEvent testEvent =
mock(ContextRefreshedEvent.class);
+
+ private final GrpcClientEventListener testGrpcClientEventListener =
mock(GrpcClientEventListener.class);
+
+ @Test
+ public void testOnApplicationEvent() {
+ GrpcServerBuilder testGrpcServerBuilder = () ->
ServerBuilder.forPort(8088);
+
+ GrpcServerRunner testGrpcServerRunner = new
GrpcServerRunner(testGrpcServerBuilder, testGrpcClientEventListener);
+
+ testGrpcServerRunner.onApplicationEvent(testEvent);
+ }
+}