This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-go-samples.git
The following commit(s) were added to refs/heads/master by this push:
new d7aa7cbb feat: async integrate test (#540)
d7aa7cbb is described below
commit d7aa7cbbd928a135f6745f8ab295a2baa9bbeb49
Author: ZLBer <[email protected]>
AuthorDate: Fri Mar 31 13:23:56 2023 +0800
feat: async integrate test (#540)
---
.../async/tests/integration/async_test.go | 47 +++++++++++++++++++
.../async/tests/integration/main_test.go | 52 ++++++++++++++++++++++
start_integrate_test.sh | 5 ++-
3 files changed, 103 insertions(+), 1 deletion(-)
diff --git a/integrate_test/async/tests/integration/async_test.go
b/integrate_test/async/tests/integration/async_test.go
new file mode 100644
index 00000000..aff6b9e1
--- /dev/null
+++ b/integrate_test/async/tests/integration/async_test.go
@@ -0,0 +1,47 @@
+/*
+ * 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 integration
+
+import (
+ "context"
+ "testing"
+ "time"
+)
+
+import (
+ "github.com/stretchr/testify/assert"
+)
+
+import (
+ "github.com/apache/dubbo-go-samples/async/go-client/pkg"
+)
+
+func TestAsync(t *testing.T) {
+ reqUser := &pkg.User{}
+ reqUser.ID = "003"
+ _, err := userProvider.GetUser(context.TODO(), reqUser)
+ assert.Nil(t, err)
+ // Mock do something else
+ // Wait for Callback
+ time.Sleep(time.Second)
+}
+
+func TestAsyncOneWay(t *testing.T) {
+ err := userProviderV2.SayHello(context.TODO(), "003")
+ assert.Nil(t, err)
+}
diff --git a/integrate_test/async/tests/integration/main_test.go
b/integrate_test/async/tests/integration/main_test.go
new file mode 100644
index 00000000..591a53d5
--- /dev/null
+++ b/integrate_test/async/tests/integration/main_test.go
@@ -0,0 +1,52 @@
+/*
+ * 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 integration
+
+import (
+ "testing"
+)
+
+import (
+ "dubbo.apache.org/dubbo-go/v3/config"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+
+ hessian "github.com/apache/dubbo-go-hessian2"
+)
+
+import (
+ "github.com/apache/dubbo-go-samples/async/go-client/pkg"
+)
+
+var (
+ userProvider = &pkg.UserProvider{}
+ userProviderV2 = &pkg.UserProviderV2{}
+)
+
+func TestMain(m *testing.M) {
+ hessian.RegisterJavaEnum(pkg.MAN)
+ hessian.RegisterJavaEnum(pkg.WOMAN)
+ hessian.RegisterPOJO(&pkg.User{})
+
+ config.SetConsumerService(userProvider)
+ config.SetConsumerService(userProviderV2)
+
+ err := config.Load()
+ if err != nil {
+ panic(err)
+ }
+}
diff --git a/start_integrate_test.sh b/start_integrate_test.sh
index c0ad63d2..26dd2bef 100755
--- a/start_integrate_test.sh
+++ b/start_integrate_test.sh
@@ -66,11 +66,14 @@ array+=("rpc/grpc")
array+=("rpc/jsonrpc")
array+=("rpc/triple/pb2")
-#tls
+# tls
array+=("tls/dubbo")
array+=("tls/triple")
array+=("tls/grpc")
+# async
+array+=("async")
+
# replace tls config
echo "The prefix of certificate path of the following files were replaced to
\"$(pwd)/tls\"."