-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore accidentally deleted test cases (#14170)
* recover test unit * replace rest to tri --------- Co-authored-by: xiaosheng <songxiaosheng@apache.org>
- Loading branch information
1 parent
fa71998
commit 31f4b3d
Showing
13 changed files
with
641 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...ig-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboServiceConsumerBootstrap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* 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.config.bootstrap; | ||
|
||
import org.apache.dubbo.config.MetadataReportConfig; | ||
import org.apache.dubbo.config.bootstrap.rest.UserService; | ||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig; | ||
|
||
/** | ||
* Dubbo Provider Bootstrap | ||
* | ||
* @since 2.7.5 | ||
*/ | ||
public class DubboServiceConsumerBootstrap { | ||
|
||
public static void main(String[] args) throws Exception { | ||
|
||
DubboBootstrap bootstrap = DubboBootstrap.getInstance() | ||
.application("dubbo-consumer-demo") | ||
.protocol(builder -> builder.port(20887).name("dubbo")) | ||
.registry( | ||
"zookeeper", | ||
builder -> builder.address(ZookeeperRegistryCenterConfig.getConnectionAddress() | ||
+ "?registry-type=service&subscribed-services=dubbo-provider-demo")) | ||
.metadataReport(new MetadataReportConfig(ZookeeperRegistryCenterConfig.getConnectionAddress())) | ||
.reference("echo", builder -> builder.interfaceClass(EchoService.class) | ||
.protocol("dubbo")) | ||
.reference("user", builder -> builder.interfaceClass(UserService.class) | ||
.protocol("tri")) | ||
.start(); | ||
|
||
EchoService echoService = bootstrap.getCache().get(EchoService.class); | ||
|
||
for (int i = 0; i < 500; i++) { | ||
Thread.sleep(2000L); | ||
System.out.println(echoService.echo("Hello,World")); | ||
} | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
...ig-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboServiceProviderBootstrap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* 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.config.bootstrap; | ||
|
||
import org.apache.dubbo.config.ApplicationConfig; | ||
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.rest.UserService; | ||
import org.apache.dubbo.config.bootstrap.rest.UserServiceImpl; | ||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig; | ||
|
||
import java.util.Arrays; | ||
|
||
/** | ||
* Dubbo Provider Bootstrap | ||
* | ||
* @since 2.7.5 | ||
*/ | ||
public class DubboServiceProviderBootstrap { | ||
|
||
public static void main(String[] args) { | ||
multipleRegistries(); | ||
} | ||
|
||
private static void multipleRegistries() { | ||
ProtocolConfig triProtocol = new ProtocolConfig(); | ||
triProtocol.setName("tri"); | ||
triProtocol.setId("tri"); | ||
triProtocol.setPort(-1); | ||
|
||
RegistryConfig interfaceRegistry = new RegistryConfig(); | ||
interfaceRegistry.setId("interfaceRegistry"); | ||
interfaceRegistry.setAddress(ZookeeperRegistryCenterConfig.getConnectionAddress()); | ||
|
||
RegistryConfig serviceRegistry = new RegistryConfig(); | ||
serviceRegistry.setId("serviceRegistry"); | ||
serviceRegistry.setAddress(ZookeeperRegistryCenterConfig.getConnectionAddress() + "?registry-type=service"); | ||
|
||
ServiceConfig<EchoService> echoService = new ServiceConfig<>(); | ||
echoService.setInterface(EchoService.class.getName()); | ||
echoService.setRef(new EchoServiceImpl()); | ||
|
||
ServiceConfig<UserService> userService = new ServiceConfig<>(); | ||
userService.setInterface(UserService.class.getName()); | ||
userService.setRef(new UserServiceImpl()); | ||
userService.setProtocol(triProtocol); | ||
|
||
ApplicationConfig applicationConfig = new ApplicationConfig("dubbo-provider-demo"); | ||
applicationConfig.setMetadataType("remote"); | ||
DubboBootstrap.getInstance() | ||
.application(applicationConfig) | ||
.registries(Arrays.asList(interfaceRegistry, serviceRegistry)) | ||
.protocol(builder -> builder.port(-1).name("dubbo")) | ||
.metadataReport(new MetadataReportConfig(ZookeeperRegistryCenterConfig.getConnectionAddress())) | ||
.service(echoService) | ||
.service(userService) | ||
.start() | ||
.await(); | ||
} | ||
|
||
private static void testSCCallDubbo() {} | ||
|
||
private static void testDubboCallSC() {} | ||
|
||
private static void testDubboTansormation() {} | ||
} |
41 changes: 41 additions & 0 deletions
41
...src/test/java/org/apache/dubbo/config/bootstrap/DubboServiceProviderMinimumBootstrap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* 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.config.bootstrap; | ||
|
||
import org.apache.dubbo.config.bootstrap.rest.UserService; | ||
import org.apache.dubbo.config.bootstrap.rest.UserServiceImpl; | ||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig; | ||
|
||
/** | ||
* TODO | ||
*/ | ||
public class DubboServiceProviderMinimumBootstrap { | ||
|
||
public static void main(String[] args) { | ||
DubboBootstrap.getInstance() | ||
.application("dubbo-provider-demo") | ||
.registry(builder -> builder.address( | ||
ZookeeperRegistryCenterConfig.getConnectionAddress() + "?registry-type=service")) | ||
.protocol(builder -> builder.port(-1).name("dubbo")) | ||
.service("echo", builder -> builder.interfaceClass(EchoService.class) | ||
.ref(new EchoServiceImpl())) | ||
.service("user", builder -> builder.interfaceClass(UserService.class) | ||
.ref(new UserServiceImpl())) | ||
.start() | ||
.await(); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
...i/src/test/java/org/apache/dubbo/config/bootstrap/NacosDubboServiceConsumerBootstrap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* 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.config.bootstrap; | ||
|
||
import org.apache.dubbo.config.ApplicationConfig; | ||
import org.apache.dubbo.config.bootstrap.rest.UserService; | ||
|
||
import static org.apache.dubbo.common.constants.CommonConstants.REMOTE_METADATA_STORAGE_TYPE; | ||
|
||
/** | ||
* Dubbo Provider Bootstrap | ||
* | ||
* @since 2.7.5 | ||
*/ | ||
public class NacosDubboServiceConsumerBootstrap { | ||
|
||
public static void main(String[] args) throws Exception { | ||
|
||
ApplicationConfig applicationConfig = new ApplicationConfig("dubbo-nacos-consumer-demo"); | ||
applicationConfig.setMetadataType(REMOTE_METADATA_STORAGE_TYPE); | ||
DubboBootstrap bootstrap = DubboBootstrap.getInstance() | ||
.application(applicationConfig) | ||
// Nacos in service registry type | ||
.registry("nacos", builder -> builder.address("nacos://127.0.0.1:8848?registry-type=service") | ||
.useAsConfigCenter(true) | ||
.useAsMetadataCenter(true)) | ||
// Nacos in traditional registry type | ||
// .registry("nacos-traditional", builder -> builder.address("nacos://127.0.0.1:8848")) | ||
.reference("echo", builder -> builder.interfaceClass(EchoService.class) | ||
.protocol("dubbo")) | ||
.reference("user", builder -> builder.interfaceClass(UserService.class) | ||
.protocol("tri")) | ||
.start(); | ||
|
||
EchoService echoService = bootstrap.getCache().get(EchoService.class); | ||
UserService userService = bootstrap.getCache().get(UserService.class); | ||
|
||
for (int i = 0; i < 5; i++) { | ||
Thread.sleep(2000L); | ||
System.out.println(echoService.echo("Hello,World")); | ||
System.out.println(userService.getUser(i * 1L)); | ||
} | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
...i/src/test/java/org/apache/dubbo/config/bootstrap/NacosDubboServiceProviderBootstrap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
*/ | ||
package org.apache.dubbo.config.bootstrap; | ||
|
||
import org.apache.dubbo.config.ApplicationConfig; | ||
import org.apache.dubbo.config.bootstrap.rest.UserService; | ||
import org.apache.dubbo.config.bootstrap.rest.UserServiceImpl; | ||
|
||
import static org.apache.dubbo.common.constants.CommonConstants.REMOTE_METADATA_STORAGE_TYPE; | ||
import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_TYPE_KEY; | ||
import static org.apache.dubbo.common.constants.RegistryConstants.SERVICE_REGISTRY_TYPE; | ||
|
||
/** | ||
* Dubbo Provider Bootstrap | ||
* | ||
* @since 2.7.5 | ||
*/ | ||
public class NacosDubboServiceProviderBootstrap { | ||
|
||
public static void main(String[] args) { | ||
ApplicationConfig applicationConfig = new ApplicationConfig("dubbo-nacos-provider-demo"); | ||
applicationConfig.setMetadataType(REMOTE_METADATA_STORAGE_TYPE); | ||
DubboBootstrap.getInstance() | ||
.application(applicationConfig) | ||
// Nacos in service registry type | ||
.registry("nacos", builder -> builder.address("nacos://127.0.0.1:8848?username=nacos&password=nacos") | ||
.parameter(REGISTRY_TYPE_KEY, SERVICE_REGISTRY_TYPE)) | ||
// Nacos in traditional registry type | ||
// .registry("nacos-traditional", builder -> builder.address("nacos://127.0.0.1:8848")) | ||
.protocol("dubbo", builder -> builder.port(20885).name("dubbo")) | ||
.protocol("tri", builder -> builder.port(9090).name("tri")) | ||
.service(builder -> builder.id("echo") | ||
.interfaceClass(EchoService.class) | ||
.ref(new EchoServiceImpl()) | ||
.protocolIds("dubbo")) | ||
.service(builder -> builder.id("user") | ||
.interfaceClass(UserService.class) | ||
.ref(new UserServiceImpl()) | ||
.protocolIds("tri")) | ||
.start() | ||
.await(); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...c/test/java/org/apache/dubbo/config/bootstrap/ZookeeperDubboServiceConsumerBootstrap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* 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.config.bootstrap; | ||
|
||
import org.apache.dubbo.config.bootstrap.rest.UserService; | ||
import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig; | ||
|
||
import static org.apache.dubbo.common.constants.CommonConstants.COMPOSITE_METADATA_STORAGE_TYPE; | ||
import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_TYPE_KEY; | ||
import static org.apache.dubbo.common.constants.RegistryConstants.SERVICE_REGISTRY_TYPE; | ||
|
||
/** | ||
* Dubbo Provider Bootstrap | ||
* | ||
* @since 2.7.5 | ||
*/ | ||
public class ZookeeperDubboServiceConsumerBootstrap { | ||
|
||
public static void main(String[] args) throws Exception { | ||
|
||
DubboBootstrap bootstrap = DubboBootstrap.getInstance() | ||
.application("zookeeper-dubbo-consumer", app -> app.metadata(COMPOSITE_METADATA_STORAGE_TYPE)) | ||
.registry("zookeeper", builder -> builder.address(ZookeeperRegistryCenterConfig.getConnectionAddress()) | ||
.parameter(REGISTRY_TYPE_KEY, SERVICE_REGISTRY_TYPE) | ||
.useAsConfigCenter(true) | ||
.useAsMetadataCenter(true)) | ||
.reference("echo", builder -> builder.interfaceClass(EchoService.class) | ||
.protocol("dubbo") | ||
.services("zookeeper-dubbo-provider")) | ||
.reference("user", builder -> builder.interfaceClass(UserService.class) | ||
.protocol("tri")) | ||
.start(); | ||
|
||
EchoService echoService = bootstrap.getCache().get(EchoService.class); | ||
UserService userService = bootstrap.getCache().get(UserService.class); | ||
|
||
for (int i = 0; i < 5; i++) { | ||
Thread.sleep(2000L); | ||
System.out.println(echoService.echo("Hello,World")); | ||
System.out.println(userService.getUser(i * 1L)); | ||
} | ||
|
||
bootstrap.stop(); | ||
} | ||
} |
Oops, something went wrong.