diff --git a/99-integration/dubbo-samples-test-13439/case-configuration.yml b/99-integration/dubbo-samples-test-13439/case-configuration.yml new file mode 100644 index 0000000000..e48af0d3b5 --- /dev/null +++ b/99-integration/dubbo-samples-test-13439/case-configuration.yml @@ -0,0 +1,57 @@ +# 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. + + +services: + nacos: + image: nacos/nacos-server:2.0.0 + environment: + - PREFER_HOST_MODE=hostname + - MODE=standalone + - NACOS_AUTH_ENABLE=false + - JVM_XMS=512m + - JVM_XMX=512m + - JVM_XMN=256m + + dubbo-samples-test-13439-provider: + type: app + basedir: dubbo-samples-test-13439-provider + mainClass: org.apache.dubbo.samples.provider.ProviderApplication + systemProps: + - nacos.address=nacos + - nacos.port=8848 + waitPortsBeforeRun: + - nacos:8848 + checkPorts: + - 10001 + checkLog: "DubboBootstrap awaiting" + depends_on: + - nacos + + dubbo-samples-test-13439-consumer: + type: test + basedir: dubbo-samples-test-13439-consumer + tests: + - "**/*IT.class" + systemProps: + - nacos.address=nacos + - nacos.port=8848 + waitPortsBeforeRun: + - nacos:8848 + - dubbo-samples-test-13439-provider:10001 + depends_on: + - nacos + - dubbo-samples-test-13439-provider diff --git a/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-api/pom.xml b/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-api/pom.xml new file mode 100644 index 0000000000..fe3a7b6717 --- /dev/null +++ b/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-api/pom.xml @@ -0,0 +1,57 @@ + + + + + 4.0.0 + + dubbo-samples-test-13439 + org.apache.dubbo + 1.0-SNAPSHOT + + + dubbo-samples-test-13439-api + Dubbo Samples Test for 13439 api + + + + com.squareup.okhttp3 + okhttp + ${okhttp.version} + + + + org.apache.dubbo + dubbo + ${dubbo.version} + + + + com.alibaba.nacos + nacos-client + + + + org.apache.logging.log4j + log4j-slf4j-impl + ${log4j2.version} + + + + diff --git a/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-api/src/main/java/org/apache/dubbo/samples/api/GreetService.java b/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-api/src/main/java/org/apache/dubbo/samples/api/GreetService.java new file mode 100644 index 0000000000..c61e0f57c7 --- /dev/null +++ b/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-api/src/main/java/org/apache/dubbo/samples/api/GreetService.java @@ -0,0 +1,39 @@ +/* + * 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.dubbo.samples.api; + +public interface GreetService { + + String greet(String msg); + + String HOST = System.getProperty("nacos.address") + ":" + System.getProperty("nacos.port"); + + String NACOS_ADDR = "nacos://"+HOST; + + String NACOS_NAMESPACE_CONSOLE_PATH = "http://"+HOST+"/nacos/v1/console/namespaces"; + + String NACOS_NAMESPACE_NAME_1 = "DUBBO-TEST-1"; + + String NACOS_NAMESPACE_NAME_2 = "DUBBO-TEST-2"; + + String NACOS_NAMESPACE_1_PATH = NACOS_ADDR + "?namespace="+NACOS_NAMESPACE_NAME_1; + + String NACOS_NAMESPACE_2_PATH = NACOS_ADDR + "?namespace="+NACOS_NAMESPACE_NAME_2; + + int PORT = 10001; +} diff --git a/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-consumer/pom.xml b/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-consumer/pom.xml new file mode 100644 index 0000000000..4e68ecc8fc --- /dev/null +++ b/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-consumer/pom.xml @@ -0,0 +1,46 @@ + + + + + 4.0.0 + + org.apache.dubbo + dubbo-samples-test-13439 + 1.0-SNAPSHOT + + + dubbo-samples-test-13439-consumer + Dubbo Samples Test for 13439 consumer + + + + org.apache.dubbo + dubbo-samples-test-13439-api + + + + junit + junit + test + ${junit.version} + + + + diff --git a/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-consumer/src/test/java/org/apache/dubbo/samples/consumer/GreetServiceIT.java b/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-consumer/src/test/java/org/apache/dubbo/samples/consumer/GreetServiceIT.java new file mode 100644 index 0000000000..33bdd5ef08 --- /dev/null +++ b/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-consumer/src/test/java/org/apache/dubbo/samples/consumer/GreetServiceIT.java @@ -0,0 +1,48 @@ +/* + * 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.dubbo.samples.consumer; + +import org.apache.dubbo.config.MetadataReportConfig; +import org.apache.dubbo.config.ProtocolConfig; +import org.apache.dubbo.config.ReferenceConfig; +import org.apache.dubbo.config.RegistryConfig; +import org.apache.dubbo.config.bootstrap.DubboBootstrap; +import org.apache.dubbo.samples.api.GreetService; +import org.junit.Assert; +import org.junit.Test; + + +public class GreetServiceIT { + + @Test + public void test(){ + System.setProperty("dubbo.application.qos-enable","false"); + RegistryConfig registryConfig = new RegistryConfig(GreetService.NACOS_ADDR); + registryConfig.setRegisterMode("instance"); + ReferenceConfig referenceConfig = new ReferenceConfig<>(); + referenceConfig.setInterface(GreetService.class); + DubboBootstrap bootstrap = DubboBootstrap.getInstance() + .application("GreetConsumerApplication") + .registry(registryConfig) + .metadataReport(new MetadataReportConfig(GreetService.NACOS_NAMESPACE_2_PATH)) + .protocol(new ProtocolConfig("dubbo", GreetService.PORT)) + .reference(referenceConfig); + bootstrap.start(); + Assert.assertEquals("Hello:world",referenceConfig.get().greet("world")); + } +} diff --git a/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-consumer/src/test/resources/log4j2.xml b/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-consumer/src/test/resources/log4j2.xml new file mode 100644 index 0000000000..69e1321d22 --- /dev/null +++ b/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-consumer/src/test/resources/log4j2.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + diff --git a/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-provider/pom.xml b/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-provider/pom.xml new file mode 100644 index 0000000000..d2a30aa218 --- /dev/null +++ b/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-provider/pom.xml @@ -0,0 +1,39 @@ + + + + + 4.0.0 + + org.apache.dubbo + dubbo-samples-test-13439 + 1.0-SNAPSHOT + + + dubbo-samples-test-13439-provider + Dubbo Samples Test for 13439 provider + + + + org.apache.dubbo + dubbo-samples-test-13439-api + + + + diff --git a/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-provider/src/main/java/org/apache/dubbo/samples/provider/GreetServiceImpl.java b/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-provider/src/main/java/org/apache/dubbo/samples/provider/GreetServiceImpl.java new file mode 100644 index 0000000000..959f15cf08 --- /dev/null +++ b/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-provider/src/main/java/org/apache/dubbo/samples/provider/GreetServiceImpl.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.dubbo.samples.provider; + +import org.apache.dubbo.samples.api.GreetService; + +public class GreetServiceImpl implements GreetService { + + @Override + public String greet(String msg) { + return "Hello:"+msg; + } + +} diff --git a/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-provider/src/main/java/org/apache/dubbo/samples/provider/ProviderApplication.java b/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-provider/src/main/java/org/apache/dubbo/samples/provider/ProviderApplication.java new file mode 100644 index 0000000000..7841559ef0 --- /dev/null +++ b/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-provider/src/main/java/org/apache/dubbo/samples/provider/ProviderApplication.java @@ -0,0 +1,83 @@ +/* + * 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.dubbo.samples.provider; + +import okhttp3.MediaType; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import org.apache.dubbo.config.MetadataReportConfig; +import org.apache.dubbo.config.ProtocolConfig; +import org.apache.dubbo.config.RegistryConfig; +import org.apache.dubbo.config.ServiceConfig; +import org.apache.dubbo.config.bootstrap.DubboBootstrap; +import org.apache.dubbo.samples.api.GreetService; + +import java.io.IOException; + +public class ProviderApplication { + + public static void main(String[] args) throws IOException { + prepareNacosServer(); + System.setProperty("dubbo.application.qos-enable","false"); + ServiceConfig serviceConfig = new ServiceConfig<>(); + serviceConfig.setRef(new org.apache.dubbo.samples.provider.GreetServiceImpl()); + serviceConfig.setInterface(GreetService.class); + RegistryConfig registryConfig = new RegistryConfig(GreetService.NACOS_ADDR); + registryConfig.setRegisterMode("instance"); + + DubboBootstrap bootstrap = DubboBootstrap.getInstance() + .application("GreetProviderApplication") + .registry(registryConfig) + .metadataReport(new MetadataReportConfig(GreetService.NACOS_NAMESPACE_1_PATH)) + .metadataReport(new MetadataReportConfig(GreetService.NACOS_NAMESPACE_2_PATH)) + .protocol(new ProtocolConfig("dubbo", GreetService.PORT)) + .service(serviceConfig); + bootstrap.start().await(); + } + + private static void prepareNacosServer() throws IOException{ + OkHttpClient client = new OkHttpClient().newBuilder() + .build(); + MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); + RequestBody body = RequestBody.create(mediaType, buildRequestContent(GreetService.NACOS_NAMESPACE_NAME_1)); + Request request = new Request.Builder() + .url(GreetService.NACOS_NAMESPACE_CONSOLE_PATH) + .method("POST", body) + .build(); + RequestBody body2 = RequestBody.create(mediaType, buildRequestContent(GreetService.NACOS_NAMESPACE_NAME_2)); + Request request2 = new Request.Builder() + .url(GreetService.NACOS_NAMESPACE_CONSOLE_PATH) + .method("POST", body2) + .build(); + try ( + Response response = client.newCall(request).execute(); + Response response2 = client.newCall(request2).execute(); + ) { + if (!response.isSuccessful() || !response2.isSuccessful()) { + throw new IOException("Can not access nacos server."); + } + } + } + + private static String buildRequestContent(String namespaceName){ + return "customNamespaceId="+namespaceName + "&namespaceName="+namespaceName+"&namespaceDesc="+namespaceName+"&namespaceID="; + } + +} diff --git a/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-provider/src/main/resources/log4j2.xml b/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-provider/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..69e1321d22 --- /dev/null +++ b/99-integration/dubbo-samples-test-13439/dubbo-samples-test-13439-provider/src/main/resources/log4j2.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + diff --git a/99-integration/dubbo-samples-test-13439/pom.xml b/99-integration/dubbo-samples-test-13439/pom.xml new file mode 100644 index 0000000000..284290f87b --- /dev/null +++ b/99-integration/dubbo-samples-test-13439/pom.xml @@ -0,0 +1,76 @@ + + + + + 4.0.0 + + org.apache + apache + 23 + + + + org.apache.dubbo + dubbo-samples-test-13439 + Dubbo Samples Test for 13439 + 1.0-SNAPSHOT + pom + + + dubbo-samples-test-13439-api + dubbo-samples-test-13439-provider + dubbo-samples-test-13439-consumer + + + + 8 + 8 + 3.2.9 + 2.20.0 + 4.9.0 + 4.13.2 + + + + + + org.apache.dubbo + dubbo-samples-test-13439-api + ${project.version} + + + org.apache.dubbo + dubbo-dependencies-bom + ${dubbo.version} + pom + import + + + org.apache.dubbo + dubbo-bom + ${dubbo.version} + pom + import + + + + + + diff --git a/99-integration/pom.xml b/99-integration/pom.xml index 1f9d9100d4..bc150c3b5b 100644 --- a/99-integration/pom.xml +++ b/99-integration/pom.xml @@ -72,6 +72,7 @@ dubbo-samples-test-13224 dubbo-samples-test-13360-32x dubbo-samples-test-13360-33x + dubbo-samples-test-13439 dubbo-samples-test-abc-async dubbo-samples-test-register dubbo-samples-test-register-3-3