You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2020/12/01 12:24:50 UTC

[servicecomb-java-chassis] branch master updated: add an example and test case for same class/interface name (#2093)

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

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git


The following commit(s) were added to refs/heads/master by this push:
     new b768f21  add an example and test case for same class/interface name (#2093)
b768f21 is described below

commit b768f2140367da06ddb8578e0e66467f159d357b
Author: bao liu <bi...@qq.com>
AuthorDate: Tue Dec 1 20:24:42 2020 +0800

    add an example and test case for same class/interface name (#2093)
---
 .../demo/pojo/client/TestSameService.java          | 68 ++++++++++++++++++++++
 .../demo/pojo/server/same/pk1/SameInterface.java   | 25 ++++++++
 .../pojo/server/same/pk1/SameInterfaceImpl.java    | 30 ++++++++++
 .../demo/pojo/server/same/pk1/SameService.java     | 32 ++++++++++
 .../demo/pojo/server/same/pk2/SameInterface.java   | 25 ++++++++
 .../pojo/server/same/pk2/SameInterfaceImpl.java    | 30 ++++++++++
 .../demo/pojo/server/same/pk2/SameService.java     | 32 ++++++++++
 7 files changed, 242 insertions(+)

diff --git a/demo/demo-pojo/pojo-client/src/main/java/org/apache/servicecomb/demo/pojo/client/TestSameService.java b/demo/demo-pojo/pojo-client/src/main/java/org/apache/servicecomb/demo/pojo/client/TestSameService.java
new file mode 100644
index 0000000..4f36b58
--- /dev/null
+++ b/demo/demo-pojo/pojo-client/src/main/java/org/apache/servicecomb/demo/pojo/client/TestSameService.java
@@ -0,0 +1,68 @@
+/*
+ * 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.servicecomb.demo.pojo.client;
+
+import org.apache.servicecomb.demo.CategorizedTestCase;
+import org.apache.servicecomb.demo.TestMgr;
+import org.apache.servicecomb.provider.pojo.RpcReference;
+import org.springframework.stereotype.Component;
+
+import io.swagger.annotations.SwaggerDefinition;
+
+@Component
+public class TestSameService implements CategorizedTestCase {
+  @SwaggerDefinition(basePath = "/SameInterface1")
+  public interface SameInterface1 {
+    public String sayHello(String name);
+  }
+
+  @SwaggerDefinition(basePath = "/SameInterface2")
+  public interface SameInterface2 {
+    public String sayHello(String name);
+  }
+
+  @SwaggerDefinition(basePath = "/SameService1")
+  public interface SameService1 {
+    public String sayHello(String name);
+  }
+
+  @SwaggerDefinition(basePath = "/SameService2")
+  public interface SameService2 {
+    public String sayHello(String name);
+  }
+
+  @RpcReference(microserviceName = "pojo", schemaId = "SameService1")
+  SameService1 sameService1;
+
+  @RpcReference(microserviceName = "pojo", schemaId = "SameService2")
+  SameService2 sameService2;
+
+  @RpcReference(microserviceName = "pojo", schemaId = "SameInterface1")
+  SameInterface1 sameInterface1;
+
+  @RpcReference(microserviceName = "pojo", schemaId = "SameInterface2")
+  SameInterface2 sameInterface2;
+
+  @Override
+  public void testAllTransport() throws Exception {
+    TestMgr.check("pk1-svc-1", sameService1.sayHello("1"));
+    TestMgr.check("pk2-svc-1", sameService2.sayHello("1"));
+    TestMgr.check("pk1-inf-1", sameInterface1.sayHello("1"));
+    TestMgr.check("pk2-inf-1", sameInterface2.sayHello("1"));
+  }
+}
diff --git a/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/same/pk1/SameInterface.java b/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/same/pk1/SameInterface.java
new file mode 100644
index 0000000..d6d58e7
--- /dev/null
+++ b/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/same/pk1/SameInterface.java
@@ -0,0 +1,25 @@
+/*
+ * 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.servicecomb.demo.pojo.server.same.pk1;
+
+import io.swagger.annotations.SwaggerDefinition;
+
+@SwaggerDefinition(basePath = "/SameInterface1")
+public interface SameInterface {
+  public String sayHello(String name);
+}
diff --git a/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/same/pk1/SameInterfaceImpl.java b/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/same/pk1/SameInterfaceImpl.java
new file mode 100644
index 0000000..e0f79bb
--- /dev/null
+++ b/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/same/pk1/SameInterfaceImpl.java
@@ -0,0 +1,30 @@
+/*
+ * 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.servicecomb.demo.pojo.server.same.pk1;
+
+import org.apache.servicecomb.provider.pojo.RpcSchema;
+import org.springframework.stereotype.Component;
+
+@RpcSchema(schemaId = "SameInterface1", schemaInterface = SameInterface.class)
+@Component("SameInterface1")
+public class SameInterfaceImpl implements SameInterface {
+  @Override
+  public String sayHello(String name) {
+    return "pk1-inf-" + name;
+  }
+}
diff --git a/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/same/pk1/SameService.java b/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/same/pk1/SameService.java
new file mode 100644
index 0000000..08540e1
--- /dev/null
+++ b/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/same/pk1/SameService.java
@@ -0,0 +1,32 @@
+/*
+ * 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.servicecomb.demo.pojo.server.same.pk1;
+
+import org.apache.servicecomb.provider.pojo.RpcSchema;
+import org.springframework.stereotype.Component;
+
+import io.swagger.annotations.SwaggerDefinition;
+
+@RpcSchema(schemaId = "SameService1")
+@Component("SameService1")
+@SwaggerDefinition(basePath = "/SameService1")
+public class SameService {
+  public String sayHello(String name) {
+    return "pk1-svc-" + name;
+  }
+}
diff --git a/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/same/pk2/SameInterface.java b/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/same/pk2/SameInterface.java
new file mode 100644
index 0000000..45c99e0
--- /dev/null
+++ b/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/same/pk2/SameInterface.java
@@ -0,0 +1,25 @@
+/*
+ * 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.servicecomb.demo.pojo.server.same.pk2;
+
+import io.swagger.annotations.SwaggerDefinition;
+
+@SwaggerDefinition(basePath = "/SameInterface2")
+public interface SameInterface {
+  public String sayHello(String name);
+}
diff --git a/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/same/pk2/SameInterfaceImpl.java b/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/same/pk2/SameInterfaceImpl.java
new file mode 100644
index 0000000..59080d8
--- /dev/null
+++ b/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/same/pk2/SameInterfaceImpl.java
@@ -0,0 +1,30 @@
+/*
+ * 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.servicecomb.demo.pojo.server.same.pk2;
+
+import org.apache.servicecomb.provider.pojo.RpcSchema;
+import org.springframework.stereotype.Component;
+
+@RpcSchema(schemaId = "SameInterface2", schemaInterface = SameInterface.class)
+@Component("SameInterface2")
+public class SameInterfaceImpl implements SameInterface {
+  @Override
+  public String sayHello(String name) {
+    return "pk2-inf-" + name;
+  }
+}
diff --git a/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/same/pk2/SameService.java b/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/same/pk2/SameService.java
new file mode 100644
index 0000000..6ebade7
--- /dev/null
+++ b/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/same/pk2/SameService.java
@@ -0,0 +1,32 @@
+/*
+ * 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.servicecomb.demo.pojo.server.same.pk2;
+
+import org.apache.servicecomb.provider.pojo.RpcSchema;
+import org.springframework.stereotype.Component;
+
+import io.swagger.annotations.SwaggerDefinition;
+
+@RpcSchema(schemaId = "SameService2")
+@Component("SameService2")
+@SwaggerDefinition(basePath = "/SameService2")
+public class SameService {
+  public String sayHello(String name) {
+    return "pk2-svc-" + name;
+  }
+}