Merge branch 'apache-3.1' into apache-3.2
# Conflicts: # dubbo-common/src/test/java/org/apache/dubbo/common/utils/JsonUtilsTest.java # dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/migration/model/MigrationRuleTest.java # dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/api/ConnectionTest.java # dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/api/MultiplexProtocolConnectionManagerTest.java # dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/api/SingleProtocolConnectionManagerTest.java # dubbo-remoting/dubbo-remoting-netty4/src/test/java/org/apache/dubbo/remoting/transport/netty4/NettyChannelTest.java # dubbo-remoting/dubbo-remoting-netty4/src/test/java/org/apache/dubbo/remoting/transport/netty4/PortUnificationExchangerTest.java # dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/TripleInvokerTest.java # dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/transport/WriteQueueTest.java
This commit is contained in:
commit
1efe576197
|
|
@ -20,6 +20,7 @@ import org.apache.dubbo.common.URL;
|
||||||
import org.apache.dubbo.rpc.cluster.configurator.absent.AbsentConfigurator;
|
import org.apache.dubbo.rpc.cluster.configurator.absent.AbsentConfigurator;
|
||||||
import org.apache.dubbo.rpc.cluster.configurator.override.OverrideConfigurator;
|
import org.apache.dubbo.rpc.cluster.configurator.override.OverrideConfigurator;
|
||||||
import org.apache.dubbo.rpc.cluster.configurator.parser.ConfigParser;
|
import org.apache.dubbo.rpc.cluster.configurator.parser.ConfigParser;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
|
@ -30,10 +31,10 @@ import java.util.Optional;
|
||||||
/**
|
/**
|
||||||
* {@link Configurator}
|
* {@link Configurator}
|
||||||
*/
|
*/
|
||||||
public class ConfiguratorTest {
|
class ConfiguratorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() throws Exception {
|
void test() throws Exception {
|
||||||
|
|
||||||
Optional<List<Configurator>> emptyOptional = Configurator.toConfigurators(Collections.emptyList());
|
Optional<List<Configurator>> emptyOptional = Configurator.toConfigurators(Collections.emptyList());
|
||||||
Assertions.assertEquals(Optional.empty(), emptyOptional);
|
Assertions.assertEquals(Optional.empty(), emptyOptional);
|
||||||
|
|
|
||||||
|
|
@ -51,13 +51,13 @@ import static org.apache.dubbo.common.constants.CommonConstants.TAG_KEY;
|
||||||
import static org.apache.dubbo.rpc.cluster.router.mesh.route.MeshRuleConstants.MESH_RULE_DATA_ID_SUFFIX;
|
import static org.apache.dubbo.rpc.cluster.router.mesh.route.MeshRuleConstants.MESH_RULE_DATA_ID_SUFFIX;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
public class RouterChainTest {
|
class RouterChainTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* verify the router and state router loaded by default
|
* verify the router and state router loaded by default
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testBuildRouterChain() {
|
void testBuildRouterChain() {
|
||||||
RouterChain<DemoService> routerChain = createRouterChanin();
|
RouterChain<DemoService> routerChain = createRouterChanin();
|
||||||
Assertions.assertEquals(0, routerChain.getRouters().size());
|
Assertions.assertEquals(0, routerChain.getRouters().size());
|
||||||
Assertions.assertEquals(5, routerChain.getStateRouters().size());
|
Assertions.assertEquals(5, routerChain.getStateRouters().size());
|
||||||
|
|
@ -78,7 +78,7 @@ public class RouterChainTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRoute() {
|
void testRoute() {
|
||||||
RouterChain<DemoService> routerChain = createRouterChanin();
|
RouterChain<DemoService> routerChain = createRouterChanin();
|
||||||
|
|
||||||
// mockInvoker will be filtered out by MockInvokersSelector
|
// mockInvoker will be filtered out by MockInvokersSelector
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public class StickyTest {
|
class StickyTest {
|
||||||
|
|
||||||
private List<Invoker<StickyTest>> invokers = new ArrayList<Invoker<StickyTest>>();
|
private List<Invoker<StickyTest>> invokers = new ArrayList<Invoker<StickyTest>>();
|
||||||
|
|
||||||
|
|
@ -74,33 +74,33 @@ public class StickyTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStickyNoCheck() {
|
void testStickyNoCheck() {
|
||||||
int count = testSticky("t1", false);
|
int count = testSticky("t1", false);
|
||||||
System.out.println(count);
|
System.out.println(count);
|
||||||
Assertions.assertTrue(count > 0 && count <= runs);
|
Assertions.assertTrue(count > 0 && count <= runs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStickyForceCheck() {
|
void testStickyForceCheck() {
|
||||||
int count = testSticky("t2", true);
|
int count = testSticky("t2", true);
|
||||||
Assertions.assertTrue(count == 0 || count == runs);
|
Assertions.assertTrue(count == 0 || count == runs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMethodStickyNoCheck() {
|
void testMethodStickyNoCheck() {
|
||||||
int count = testSticky("method1", false);
|
int count = testSticky("method1", false);
|
||||||
System.out.println(count);
|
System.out.println(count);
|
||||||
Assertions.assertTrue(count > 0 && count <= runs);
|
Assertions.assertTrue(count > 0 && count <= runs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMethodStickyForceCheck() {
|
void testMethodStickyForceCheck() {
|
||||||
int count = testSticky("method1", true);
|
int count = testSticky("method1", true);
|
||||||
Assertions.assertTrue(count == 0 || count == runs);
|
Assertions.assertTrue(count == 0 || count == runs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMethodsSticky() {
|
void testMethodsSticky() {
|
||||||
for (int i = 0; i < 100; i++) {//Two different methods should always use the same invoker every time.
|
for (int i = 0; i < 100; i++) {//Two different methods should always use the same invoker every time.
|
||||||
int count1 = testSticky("method1", true);
|
int count1 = testSticky("method1", true);
|
||||||
int count2 = testSticky("method2", true);
|
int count2 = testSticky("method2", true);
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,11 @@ import java.util.Map;
|
||||||
/**
|
/**
|
||||||
* OverrideConfiguratorTest
|
* OverrideConfiguratorTest
|
||||||
*/
|
*/
|
||||||
public class AbsentConfiguratorTest {
|
class AbsentConfiguratorTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOverrideApplication() {
|
void testOverrideApplication() {
|
||||||
AbsentConfigurator configurator = new AbsentConfigurator(URL.valueOf("override://foo@0.0.0.0/com.foo.BarService?timeout=200"));
|
AbsentConfigurator configurator = new AbsentConfigurator(URL.valueOf("override://foo@0.0.0.0/com.foo.BarService?timeout=200"));
|
||||||
|
|
||||||
URL url = configurator.configure(URL.valueOf(UrlConstant.URL_CONSUMER));
|
URL url = configurator.configure(URL.valueOf(UrlConstant.URL_CONSUMER));
|
||||||
|
|
@ -50,7 +50,7 @@ public class AbsentConfiguratorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOverrideHost() {
|
void testOverrideHost() {
|
||||||
AbsentConfigurator configurator = new AbsentConfigurator(URL.valueOf("override://" + NetUtils.getLocalHost() + "/com.foo.BarService?timeout=200"));
|
AbsentConfigurator configurator = new AbsentConfigurator(URL.valueOf("override://" + NetUtils.getLocalHost() + "/com.foo.BarService?timeout=200"));
|
||||||
|
|
||||||
URL url = configurator.configure(URL.valueOf(UrlConstant.URL_CONSUMER));
|
URL url = configurator.configure(URL.valueOf(UrlConstant.URL_CONSUMER));
|
||||||
|
|
@ -70,7 +70,7 @@ public class AbsentConfiguratorTest {
|
||||||
|
|
||||||
// Test the version after 2.7
|
// Test the version after 2.7
|
||||||
@Test
|
@Test
|
||||||
public void testAbsentForVersion27() {
|
void testAbsentForVersion27() {
|
||||||
{
|
{
|
||||||
String consumerUrlV27 = "dubbo://172.24.160.179/com.foo.BarService?application=foo&side=consumer&timeout=100";
|
String consumerUrlV27 = "dubbo://172.24.160.179/com.foo.BarService?application=foo&side=consumer&timeout=100";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,10 @@ import java.util.Map;
|
||||||
/**
|
/**
|
||||||
* OverrideConfiguratorTest
|
* OverrideConfiguratorTest
|
||||||
*/
|
*/
|
||||||
public class OverrideConfiguratorTest {
|
class OverrideConfiguratorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOverride_Application() {
|
void testOverride_Application() {
|
||||||
OverrideConfigurator configurator = new OverrideConfigurator(URL.valueOf("override://foo@0.0.0.0/com.foo.BarService?timeout=200"));
|
OverrideConfigurator configurator = new OverrideConfigurator(URL.valueOf("override://foo@0.0.0.0/com.foo.BarService?timeout=200"));
|
||||||
|
|
||||||
URL url = configurator.configure(URL.valueOf(UrlConstant.URL_CONSUMER));
|
URL url = configurator.configure(URL.valueOf(UrlConstant.URL_CONSUMER));
|
||||||
|
|
@ -50,7 +50,7 @@ public class OverrideConfiguratorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOverride_Host() {
|
void testOverride_Host() {
|
||||||
OverrideConfigurator configurator = new OverrideConfigurator(URL.valueOf("override://" + NetUtils.getLocalHost() + "/com.foo.BarService?timeout=200"));
|
OverrideConfigurator configurator = new OverrideConfigurator(URL.valueOf("override://" + NetUtils.getLocalHost() + "/com.foo.BarService?timeout=200"));
|
||||||
|
|
||||||
URL url = configurator.configure(URL.valueOf(UrlConstant.URL_CONSUMER));
|
URL url = configurator.configure(URL.valueOf(UrlConstant.URL_CONSUMER));
|
||||||
|
|
@ -70,7 +70,7 @@ public class OverrideConfiguratorTest {
|
||||||
|
|
||||||
// Test the version after 2.7
|
// Test the version after 2.7
|
||||||
@Test
|
@Test
|
||||||
public void testOverrideForVersion27() {
|
void testOverrideForVersion27() {
|
||||||
{
|
{
|
||||||
String consumerUrlV27 = "dubbo://172.24.160.179/com.foo.BarService?application=foo&side=consumer&timeout=100";
|
String consumerUrlV27 = "dubbo://172.24.160.179/com.foo.BarService?application=foo&side=consumer&timeout=100";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ import static org.apache.dubbo.rpc.cluster.Constants.WEIGHT_KEY;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ConfigParserTest {
|
class ConfigParserTest {
|
||||||
|
|
||||||
private String streamToString(InputStream stream) throws IOException {
|
private String streamToString(InputStream stream) throws IOException {
|
||||||
byte[] bytes = new byte[stream.available()];
|
byte[] bytes = new byte[stream.available()];
|
||||||
|
|
@ -46,7 +46,7 @@ public class ConfigParserTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void snakeYamlBasicTest() throws IOException {
|
void snakeYamlBasicTest() throws IOException {
|
||||||
try (InputStream yamlStream = this.getClass().getResourceAsStream("/ServiceNoApp.yml")) {
|
try (InputStream yamlStream = this.getClass().getResourceAsStream("/ServiceNoApp.yml")) {
|
||||||
Yaml yaml = new Yaml(new SafeConstructor());
|
Yaml yaml = new Yaml(new SafeConstructor());
|
||||||
Map<String, Object> map = yaml.load(yamlStream);
|
Map<String, Object> map = yaml.load(yamlStream);
|
||||||
|
|
@ -56,7 +56,7 @@ public class ConfigParserTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseConfiguratorsServiceNoAppTest() throws Exception {
|
void parseConfiguratorsServiceNoAppTest() throws Exception {
|
||||||
try (InputStream yamlStream = this.getClass().getResourceAsStream("/ServiceNoApp.yml")) {
|
try (InputStream yamlStream = this.getClass().getResourceAsStream("/ServiceNoApp.yml")) {
|
||||||
List<URL> urls = ConfigParser.parseConfigurators(streamToString(yamlStream));
|
List<URL> urls = ConfigParser.parseConfigurators(streamToString(yamlStream));
|
||||||
Assertions.assertNotNull(urls);
|
Assertions.assertNotNull(urls);
|
||||||
|
|
@ -68,7 +68,7 @@ public class ConfigParserTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseConfiguratorsServiceGroupVersionTest() throws Exception {
|
void parseConfiguratorsServiceGroupVersionTest() throws Exception {
|
||||||
try (InputStream yamlStream = this.getClass().getResourceAsStream("/ServiceGroupVersion.yml")) {
|
try (InputStream yamlStream = this.getClass().getResourceAsStream("/ServiceGroupVersion.yml")) {
|
||||||
List<URL> urls = ConfigParser.parseConfigurators(streamToString(yamlStream));
|
List<URL> urls = ConfigParser.parseConfigurators(streamToString(yamlStream));
|
||||||
Assertions.assertNotNull(urls);
|
Assertions.assertNotNull(urls);
|
||||||
|
|
@ -80,7 +80,7 @@ public class ConfigParserTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseConfiguratorsServiceMultiAppsTest() throws IOException {
|
void parseConfiguratorsServiceMultiAppsTest() throws IOException {
|
||||||
try (InputStream yamlStream = this.getClass().getResourceAsStream("/ServiceMultiApps.yml")) {
|
try (InputStream yamlStream = this.getClass().getResourceAsStream("/ServiceMultiApps.yml")) {
|
||||||
List<URL> urls = ConfigParser.parseConfigurators(streamToString(yamlStream));
|
List<URL> urls = ConfigParser.parseConfigurators(streamToString(yamlStream));
|
||||||
Assertions.assertNotNull(urls);
|
Assertions.assertNotNull(urls);
|
||||||
|
|
@ -93,7 +93,7 @@ public class ConfigParserTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseConfiguratorsServiceNoRuleTest() {
|
void parseConfiguratorsServiceNoRuleTest() {
|
||||||
Assertions.assertThrows(IllegalStateException.class, () -> {
|
Assertions.assertThrows(IllegalStateException.class, () -> {
|
||||||
try (InputStream yamlStream = this.getClass().getResourceAsStream("/ServiceNoRule.yml")) {
|
try (InputStream yamlStream = this.getClass().getResourceAsStream("/ServiceNoRule.yml")) {
|
||||||
ConfigParser.parseConfigurators(streamToString(yamlStream));
|
ConfigParser.parseConfigurators(streamToString(yamlStream));
|
||||||
|
|
@ -103,7 +103,7 @@ public class ConfigParserTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseConfiguratorsAppMultiServicesTest() throws IOException {
|
void parseConfiguratorsAppMultiServicesTest() throws IOException {
|
||||||
try (InputStream yamlStream = this.getClass().getResourceAsStream("/AppMultiServices.yml")) {
|
try (InputStream yamlStream = this.getClass().getResourceAsStream("/AppMultiServices.yml")) {
|
||||||
String yamlFile = streamToString(yamlStream);
|
String yamlFile = streamToString(yamlStream);
|
||||||
List<URL> urls = ConfigParser.parseConfigurators(yamlFile);
|
List<URL> urls = ConfigParser.parseConfigurators(yamlFile);
|
||||||
|
|
@ -120,7 +120,7 @@ public class ConfigParserTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseConfiguratorsAppAnyServicesTest() throws IOException {
|
void parseConfiguratorsAppAnyServicesTest() throws IOException {
|
||||||
try (InputStream yamlStream = this.getClass().getResourceAsStream("/AppAnyServices.yml")) {
|
try (InputStream yamlStream = this.getClass().getResourceAsStream("/AppAnyServices.yml")) {
|
||||||
List<URL> urls = ConfigParser.parseConfigurators(streamToString(yamlStream));
|
List<URL> urls = ConfigParser.parseConfigurators(streamToString(yamlStream));
|
||||||
Assertions.assertNotNull(urls);
|
Assertions.assertNotNull(urls);
|
||||||
|
|
@ -135,7 +135,7 @@ public class ConfigParserTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseConfiguratorsAppNoServiceTest() throws IOException {
|
void parseConfiguratorsAppNoServiceTest() throws IOException {
|
||||||
try (InputStream yamlStream = this.getClass().getResourceAsStream("/AppNoService.yml")) {
|
try (InputStream yamlStream = this.getClass().getResourceAsStream("/AppNoService.yml")) {
|
||||||
List<URL> urls = ConfigParser.parseConfigurators(streamToString(yamlStream));
|
List<URL> urls = ConfigParser.parseConfigurators(streamToString(yamlStream));
|
||||||
Assertions.assertNotNull(urls);
|
Assertions.assertNotNull(urls);
|
||||||
|
|
@ -150,7 +150,7 @@ public class ConfigParserTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseConsumerSpecificProvidersTest() throws IOException {
|
void parseConsumerSpecificProvidersTest() throws IOException {
|
||||||
try (InputStream yamlStream = this.getClass().getResourceAsStream("/ConsumerSpecificProviders.yml")) {
|
try (InputStream yamlStream = this.getClass().getResourceAsStream("/ConsumerSpecificProviders.yml")) {
|
||||||
List<URL> urls = ConfigParser.parseConfigurators(streamToString(yamlStream));
|
List<URL> urls = ConfigParser.parseConfigurators(streamToString(yamlStream));
|
||||||
Assertions.assertNotNull(urls);
|
Assertions.assertNotNull(urls);
|
||||||
|
|
@ -166,7 +166,7 @@ public class ConfigParserTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseURLJsonArrayCompatible() {
|
void parseURLJsonArrayCompatible() {
|
||||||
|
|
||||||
String configData = "[\"override://0.0.0.0/com.xx.Service?category=configurators&timeout=6666&disabled=true&dynamic=false&enabled=true&group=dubbo&priority=1&version=1.0\" ]";
|
String configData = "[\"override://0.0.0.0/com.xx.Service?category=configurators&timeout=6666&disabled=true&dynamic=false&enabled=true&group=dubbo&priority=1&version=1.0\" ]";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ import static org.apache.dubbo.rpc.Constants.TOKEN_KEY;
|
||||||
/**
|
/**
|
||||||
* MockInvocation.java
|
* MockInvocation.java
|
||||||
*/
|
*/
|
||||||
public class MockDirInvocation implements Invocation {
|
class MockDirInvocation implements Invocation {
|
||||||
|
|
||||||
private Map<String, Object> attachments;
|
private Map<String, Object> attachments;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ import static org.apache.dubbo.rpc.cluster.Constants.RULE_KEY;
|
||||||
/**
|
/**
|
||||||
* StaticDirectory Test
|
* StaticDirectory Test
|
||||||
*/
|
*/
|
||||||
public class StaticDirectoryTest {
|
class StaticDirectoryTest {
|
||||||
private URL SCRIPT_URL = URL.valueOf("condition://0.0.0.0/com.foo.BarService");
|
private URL SCRIPT_URL = URL.valueOf("condition://0.0.0.0/com.foo.BarService");
|
||||||
|
|
||||||
private URL getRouteUrl(String rule) {
|
private URL getRouteUrl(String rule) {
|
||||||
|
|
@ -45,7 +45,7 @@ public class StaticDirectoryTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStaticDirectory() {
|
void testStaticDirectory() {
|
||||||
StateRouter router = new ConditionStateRouterFactory().getRouter(String.class, getRouteUrl(" => " + " host = " + NetUtils.getLocalHost()));
|
StateRouter router = new ConditionStateRouterFactory().getRouter(String.class, getRouteUrl(" => " + " host = " + NetUtils.getLocalHost()));
|
||||||
List<StateRouter> routers = new ArrayList<StateRouter>();
|
List<StateRouter> routers = new ArrayList<StateRouter>();
|
||||||
routers.add(router);
|
routers.add(router);
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,10 @@ import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER;
|
||||||
import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
|
import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
|
||||||
import static org.apache.dubbo.common.constants.CommonConstants.REFERENCE_FILTER_KEY;
|
import static org.apache.dubbo.common.constants.CommonConstants.REFERENCE_FILTER_KEY;
|
||||||
|
|
||||||
public class DefaultFilterChainBuilderTest {
|
class DefaultFilterChainBuilderTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuildInvokerChainForLocalReference() {
|
void testBuildInvokerChainForLocalReference() {
|
||||||
DefaultFilterChainBuilder defaultFilterChainBuilder = new DefaultFilterChainBuilder();
|
DefaultFilterChainBuilder defaultFilterChainBuilder = new DefaultFilterChainBuilder();
|
||||||
|
|
||||||
// verify that no filter is built by default
|
// verify that no filter is built by default
|
||||||
|
|
@ -69,7 +69,7 @@ public class DefaultFilterChainBuilderTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuildInvokerChainForRemoteReference() {
|
void testBuildInvokerChainForRemoteReference() {
|
||||||
DefaultFilterChainBuilder defaultFilterChainBuilder = new DefaultFilterChainBuilder();
|
DefaultFilterChainBuilder defaultFilterChainBuilder = new DefaultFilterChainBuilder();
|
||||||
|
|
||||||
// verify that no filter is built by default
|
// verify that no filter is built by default
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
package org.apache.dubbo.rpc.cluster.filter;
|
package org.apache.dubbo.rpc.cluster.filter;
|
||||||
|
|
||||||
|
|
||||||
public class DemoServiceImpl implements DemoService{
|
class DemoServiceImpl implements DemoService{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String sayHello(String name) {
|
public String sayHello(String name) {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ package org.apache.dubbo.rpc.cluster.filter;
|
||||||
* <code>TestService</code>
|
* <code>TestService</code>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class DemoServiceLocal implements DemoService {
|
class DemoServiceLocal implements DemoService {
|
||||||
|
|
||||||
public DemoServiceLocal(DemoService demoService) {
|
public DemoServiceLocal(DemoService demoService) {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ package org.apache.dubbo.rpc.cluster.filter;
|
||||||
* MockService.java
|
* MockService.java
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DemoServiceMock implements DemoService {
|
class DemoServiceMock implements DemoService {
|
||||||
public String sayHello(String name) {
|
public String sayHello(String name) {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ package org.apache.dubbo.rpc.cluster.filter;
|
||||||
* <code>TestService</code>
|
* <code>TestService</code>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class DemoServiceStub implements DemoService {
|
class DemoServiceStub implements DemoService {
|
||||||
|
|
||||||
public DemoServiceStub(DemoService demoService) {
|
public DemoServiceStub(DemoService demoService) {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ package org.apache.dubbo.rpc.cluster.filter;
|
||||||
* MockService.java
|
* MockService.java
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class MockService implements DemoService {
|
class MockService implements DemoService {
|
||||||
public String sayHello(String name) {
|
public String sayHello(String name) {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ import static org.apache.dubbo.rpc.cluster.Constants.WEIGHT_KEY;
|
||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
public class AbstractLoadBalanceTest {
|
class AbstractLoadBalanceTest {
|
||||||
|
|
||||||
private AbstractLoadBalance balance = new AbstractLoadBalance() {
|
private AbstractLoadBalance balance = new AbstractLoadBalance() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -45,7 +45,7 @@ public class AbstractLoadBalanceTest {
|
||||||
};
|
};
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetWeight() {
|
void testGetWeight() {
|
||||||
RpcInvocation invocation = new RpcInvocation();
|
RpcInvocation invocation = new RpcInvocation();
|
||||||
invocation.setMethodName("say");
|
invocation.setMethodName("say");
|
||||||
|
|
||||||
|
|
@ -63,7 +63,7 @@ public class AbstractLoadBalanceTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetRegistryWeight() {
|
void testGetRegistryWeight() {
|
||||||
RpcInvocation invocation = new RpcInvocation();
|
RpcInvocation invocation = new RpcInvocation();
|
||||||
invocation.setMethodName("say");
|
invocation.setMethodName("say");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,10 @@ import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public class ConsistentHashLoadBalanceTest extends LoadBalanceBaseTest {
|
class ConsistentHashLoadBalanceTest extends LoadBalanceBaseTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConsistentHashLoadBalanceInGenericCall() {
|
void testConsistentHashLoadBalanceInGenericCall() {
|
||||||
int runs = 10000;
|
int runs = 10000;
|
||||||
Map<Invoker, AtomicLong> genericInvokeCounter = getGenericInvokeCounter(runs, ConsistentHashLoadBalance.NAME);
|
Map<Invoker, AtomicLong> genericInvokeCounter = getGenericInvokeCounter(runs, ConsistentHashLoadBalance.NAME);
|
||||||
Map<Invoker, AtomicLong> invokeCounter = getInvokeCounter(runs, ConsistentHashLoadBalance.NAME);
|
Map<Invoker, AtomicLong> invokeCounter = getInvokeCounter(runs, ConsistentHashLoadBalance.NAME);
|
||||||
|
|
@ -62,7 +62,7 @@ public class ConsistentHashLoadBalanceTest extends LoadBalanceBaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConsistentHashLoadBalance() {
|
void testConsistentHashLoadBalance() {
|
||||||
int runs = 10000;
|
int runs = 10000;
|
||||||
long unHitedInvokerCount = 0;
|
long unHitedInvokerCount = 0;
|
||||||
Map<Invoker, Long> hitedInvokers = new HashMap<>();
|
Map<Invoker, Long> hitedInvokers = new HashMap<>();
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,10 @@ import org.junit.jupiter.api.Test;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
public class LeastActiveBalanceTest extends LoadBalanceBaseTest {
|
class LeastActiveBalanceTest extends LoadBalanceBaseTest {
|
||||||
@Disabled
|
@Disabled
|
||||||
@Test
|
@Test
|
||||||
public void testLeastActiveLoadBalance_select() {
|
void testLeastActiveLoadBalance_select() {
|
||||||
int runs = 10000;
|
int runs = 10000;
|
||||||
Map<Invoker, AtomicLong> counter = getInvokeCounter(runs, LeastActiveLoadBalance.NAME);
|
Map<Invoker, AtomicLong> counter = getInvokeCounter(runs, LeastActiveLoadBalance.NAME);
|
||||||
for (Map.Entry<Invoker, AtomicLong> entry : counter.entrySet()) {
|
for (Map.Entry<Invoker, AtomicLong> entry : counter.entrySet()) {
|
||||||
|
|
@ -40,7 +40,7 @@ public class LeastActiveBalanceTest extends LoadBalanceBaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSelectByWeight() {
|
void testSelectByWeight() {
|
||||||
int sumInvoker1 = 0;
|
int sumInvoker1 = 0;
|
||||||
int sumInvoker2 = 0;
|
int sumInvoker2 = 0;
|
||||||
int loop = 10000;
|
int loop = 10000;
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ import static org.mockito.Mockito.mock;
|
||||||
* RoundRobinLoadBalanceTest
|
* RoundRobinLoadBalanceTest
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
public class LoadBalanceBaseTest {
|
class LoadBalanceBaseTest {
|
||||||
Invocation invocation;
|
Invocation invocation;
|
||||||
Invocation genericInvocation;
|
Invocation genericInvocation;
|
||||||
List<Invoker<LoadBalanceBaseTest>> invokers = new ArrayList<Invoker<LoadBalanceBaseTest>>();
|
List<Invoker<LoadBalanceBaseTest>> invokers = new ArrayList<Invoker<LoadBalanceBaseTest>>();
|
||||||
|
|
@ -160,7 +160,7 @@ public class LoadBalanceBaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLoadBalanceWarmup() {
|
void testLoadBalanceWarmup() {
|
||||||
Assertions.assertEquals(1, calculateDefaultWarmupWeight(0));
|
Assertions.assertEquals(1, calculateDefaultWarmupWeight(0));
|
||||||
Assertions.assertEquals(1, calculateDefaultWarmupWeight(13));
|
Assertions.assertEquals(1, calculateDefaultWarmupWeight(13));
|
||||||
Assertions.assertEquals(1, calculateDefaultWarmupWeight(6 * 1000));
|
Assertions.assertEquals(1, calculateDefaultWarmupWeight(6 * 1000));
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,9 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||||
/**
|
/**
|
||||||
* RandomLoadBalance Test
|
* RandomLoadBalance Test
|
||||||
*/
|
*/
|
||||||
public class RandomLoadBalanceTest extends LoadBalanceBaseTest {
|
class RandomLoadBalanceTest extends LoadBalanceBaseTest {
|
||||||
@Test
|
@Test
|
||||||
public void testRandomLoadBalanceSelect() {
|
void testRandomLoadBalanceSelect() {
|
||||||
int runs = 1000;
|
int runs = 1000;
|
||||||
Map<Invoker, AtomicLong> counter = getInvokeCounter(runs, RandomLoadBalance.NAME);
|
Map<Invoker, AtomicLong> counter = getInvokeCounter(runs, RandomLoadBalance.NAME);
|
||||||
for (Map.Entry<Invoker, AtomicLong> entry : counter.entrySet()) {
|
for (Map.Entry<Invoker, AtomicLong> entry : counter.entrySet()) {
|
||||||
|
|
@ -55,7 +55,7 @@ public class RandomLoadBalanceTest extends LoadBalanceBaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSelectByWeight() {
|
void testSelectByWeight() {
|
||||||
int sumInvoker1 = 0;
|
int sumInvoker1 = 0;
|
||||||
int sumInvoker2 = 0;
|
int sumInvoker2 = 0;
|
||||||
int sumInvoker3 = 0;
|
int sumInvoker3 = 0;
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
@Disabled
|
@Disabled
|
||||||
public class RoundRobinLoadBalanceTest extends LoadBalanceBaseTest {
|
class RoundRobinLoadBalanceTest extends LoadBalanceBaseTest {
|
||||||
|
|
||||||
private void assertStrictWRRResult(int loop, Map<Invoker, InvokeResult> resultMap) {
|
private void assertStrictWRRResult(int loop, Map<Invoker, InvokeResult> resultMap) {
|
||||||
int invokeCount = 0;
|
int invokeCount = 0;
|
||||||
|
|
@ -47,7 +47,7 @@ public class RoundRobinLoadBalanceTest extends LoadBalanceBaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRoundRobinLoadBalanceSelect() {
|
void testRoundRobinLoadBalanceSelect() {
|
||||||
int runs = 10000;
|
int runs = 10000;
|
||||||
Map<Invoker, AtomicLong> counter = getInvokeCounter(runs, RoundRobinLoadBalance.NAME);
|
Map<Invoker, AtomicLong> counter = getInvokeCounter(runs, RoundRobinLoadBalance.NAME);
|
||||||
for (Map.Entry<Invoker, AtomicLong> entry : counter.entrySet()) {
|
for (Map.Entry<Invoker, AtomicLong> entry : counter.entrySet()) {
|
||||||
|
|
@ -57,7 +57,7 @@ public class RoundRobinLoadBalanceTest extends LoadBalanceBaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSelectByWeight() {
|
void testSelectByWeight() {
|
||||||
final Map<Invoker, InvokeResult> totalMap = new HashMap<Invoker, InvokeResult>();
|
final Map<Invoker, InvokeResult> totalMap = new HashMap<Invoker, InvokeResult>();
|
||||||
final AtomicBoolean shouldBegin = new AtomicBoolean(false);
|
final AtomicBoolean shouldBegin = new AtomicBoolean(false);
|
||||||
final int runs = 10000;
|
final int runs = 10000;
|
||||||
|
|
@ -98,7 +98,7 @@ public class RoundRobinLoadBalanceTest extends LoadBalanceBaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNodeCacheShouldNotRecycle() {
|
void testNodeCacheShouldNotRecycle() {
|
||||||
int loop = 10000;
|
int loop = 10000;
|
||||||
//tmperately add a new invoker
|
//tmperately add a new invoker
|
||||||
weightInvokers.add(weightInvokerTmp);
|
weightInvokers.add(weightInvokerTmp);
|
||||||
|
|
@ -123,7 +123,7 @@ public class RoundRobinLoadBalanceTest extends LoadBalanceBaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNodeCacheShouldRecycle() {
|
void testNodeCacheShouldRecycle() {
|
||||||
{
|
{
|
||||||
Field recycleTimeField = null;
|
Field recycleTimeField = null;
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||||
public class ShortestResponseLoadBalanceTest extends LoadBalanceBaseTest {
|
class ShortestResponseLoadBalanceTest extends LoadBalanceBaseTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(0)
|
@Order(0)
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ import java.util.stream.IntStream;
|
||||||
import java.util.stream.LongStream;
|
import java.util.stream.LongStream;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class ResultMergerTest {
|
class ResultMergerTest {
|
||||||
private MergerFactory mergerFactory;
|
private MergerFactory mergerFactory;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
|
|
@ -48,7 +48,7 @@ public class ResultMergerTest {
|
||||||
* MergerFactory test
|
* MergerFactory test
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMergerFactoryIllegalArgumentException() {
|
void testMergerFactoryIllegalArgumentException() {
|
||||||
try {
|
try {
|
||||||
mergerFactory.getMerger(null);
|
mergerFactory.getMerger(null);
|
||||||
Assertions.fail("expected IllegalArgumentException for null argument");
|
Assertions.fail("expected IllegalArgumentException for null argument");
|
||||||
|
|
@ -61,7 +61,7 @@ public class ResultMergerTest {
|
||||||
* ArrayMerger test
|
* ArrayMerger test
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testArrayMergerIllegalArgumentException() {
|
void testArrayMergerIllegalArgumentException() {
|
||||||
String[] stringArray = {"1", "2", "3"};
|
String[] stringArray = {"1", "2", "3"};
|
||||||
Integer[] integerArray = {3, 4, 5};
|
Integer[] integerArray = {3, 4, 5};
|
||||||
try {
|
try {
|
||||||
|
|
@ -76,7 +76,7 @@ public class ResultMergerTest {
|
||||||
* ArrayMerger test
|
* ArrayMerger test
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testArrayMerger() {
|
void testArrayMerger() {
|
||||||
String[] stringArray1 = {"1", "2", "3"};
|
String[] stringArray1 = {"1", "2", "3"};
|
||||||
String[] stringArray2 = {"4", "5", "6"};
|
String[] stringArray2 = {"4", "5", "6"};
|
||||||
String[] stringArray3 = {};
|
String[] stringArray3 = {};
|
||||||
|
|
@ -115,7 +115,7 @@ public class ResultMergerTest {
|
||||||
* BooleanArrayMerger test
|
* BooleanArrayMerger test
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testBooleanArrayMerger() {
|
void testBooleanArrayMerger() {
|
||||||
boolean[] arrayOne = {true, false};
|
boolean[] arrayOne = {true, false};
|
||||||
boolean[] arrayTwo = {false};
|
boolean[] arrayTwo = {false};
|
||||||
boolean[] result = mergerFactory.getMerger(boolean[].class).merge(arrayOne, arrayTwo, null);
|
boolean[] result = mergerFactory.getMerger(boolean[].class).merge(arrayOne, arrayTwo, null);
|
||||||
|
|
@ -136,7 +136,7 @@ public class ResultMergerTest {
|
||||||
* ByteArrayMerger test
|
* ByteArrayMerger test
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testByteArrayMerger() {
|
void testByteArrayMerger() {
|
||||||
byte[] arrayOne = {1, 2};
|
byte[] arrayOne = {1, 2};
|
||||||
byte[] arrayTwo = {1, 32};
|
byte[] arrayTwo = {1, 32};
|
||||||
byte[] result = mergerFactory.getMerger(byte[].class).merge(arrayOne, arrayTwo, null);
|
byte[] result = mergerFactory.getMerger(byte[].class).merge(arrayOne, arrayTwo, null);
|
||||||
|
|
@ -157,7 +157,7 @@ public class ResultMergerTest {
|
||||||
* CharArrayMerger test
|
* CharArrayMerger test
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCharArrayMerger() {
|
void testCharArrayMerger() {
|
||||||
char[] arrayOne = "hello".toCharArray();
|
char[] arrayOne = "hello".toCharArray();
|
||||||
char[] arrayTwo = "world".toCharArray();
|
char[] arrayTwo = "world".toCharArray();
|
||||||
char[] result = mergerFactory.getMerger(char[].class).merge(arrayOne, arrayTwo, null);
|
char[] result = mergerFactory.getMerger(char[].class).merge(arrayOne, arrayTwo, null);
|
||||||
|
|
@ -178,7 +178,7 @@ public class ResultMergerTest {
|
||||||
* DoubleArrayMerger test
|
* DoubleArrayMerger test
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testDoubleArrayMerger() {
|
void testDoubleArrayMerger() {
|
||||||
double[] arrayOne = {1.2d, 3.5d};
|
double[] arrayOne = {1.2d, 3.5d};
|
||||||
double[] arrayTwo = {2d, 34d};
|
double[] arrayTwo = {2d, 34d};
|
||||||
double[] result = mergerFactory.getMerger(double[].class).merge(arrayOne, arrayTwo, null);
|
double[] result = mergerFactory.getMerger(double[].class).merge(arrayOne, arrayTwo, null);
|
||||||
|
|
@ -199,7 +199,7 @@ public class ResultMergerTest {
|
||||||
* FloatArrayMerger test
|
* FloatArrayMerger test
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testFloatArrayMerger() {
|
void testFloatArrayMerger() {
|
||||||
float[] arrayOne = {1.2f, 3.5f};
|
float[] arrayOne = {1.2f, 3.5f};
|
||||||
float[] arrayTwo = {2f, 34f};
|
float[] arrayTwo = {2f, 34f};
|
||||||
float[] result = mergerFactory.getMerger(float[].class).merge(arrayOne, arrayTwo, null);
|
float[] result = mergerFactory.getMerger(float[].class).merge(arrayOne, arrayTwo, null);
|
||||||
|
|
@ -220,7 +220,7 @@ public class ResultMergerTest {
|
||||||
* IntArrayMerger test
|
* IntArrayMerger test
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testIntArrayMerger() {
|
void testIntArrayMerger() {
|
||||||
int[] arrayOne = {1, 2};
|
int[] arrayOne = {1, 2};
|
||||||
int[] arrayTwo = {2, 34};
|
int[] arrayTwo = {2, 34};
|
||||||
int[] result = mergerFactory.getMerger(int[].class).merge(arrayOne, arrayTwo, null);
|
int[] result = mergerFactory.getMerger(int[].class).merge(arrayOne, arrayTwo, null);
|
||||||
|
|
@ -241,7 +241,7 @@ public class ResultMergerTest {
|
||||||
* ListMerger test
|
* ListMerger test
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testListMerger() {
|
void testListMerger() {
|
||||||
List<Object> list1 = new ArrayList<Object>() {{
|
List<Object> list1 = new ArrayList<Object>() {{
|
||||||
add(null);
|
add(null);
|
||||||
add("1");
|
add("1");
|
||||||
|
|
@ -274,7 +274,7 @@ public class ResultMergerTest {
|
||||||
* LongArrayMerger test
|
* LongArrayMerger test
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMapArrayMerger() {
|
void testMapArrayMerger() {
|
||||||
Map<Object, Object> mapOne = new HashMap<Object, Object>() {{
|
Map<Object, Object> mapOne = new HashMap<Object, Object>() {{
|
||||||
put("11", 222);
|
put("11", 222);
|
||||||
put("223", 11);
|
put("223", 11);
|
||||||
|
|
@ -304,7 +304,7 @@ public class ResultMergerTest {
|
||||||
* LongArrayMerger test
|
* LongArrayMerger test
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testLongArrayMerger() {
|
void testLongArrayMerger() {
|
||||||
long[] arrayOne = {1L, 2L};
|
long[] arrayOne = {1L, 2L};
|
||||||
long[] arrayTwo = {2L, 34L};
|
long[] arrayTwo = {2L, 34L};
|
||||||
long[] result = mergerFactory.getMerger(long[].class).merge(arrayOne, arrayTwo, null);
|
long[] result = mergerFactory.getMerger(long[].class).merge(arrayOne, arrayTwo, null);
|
||||||
|
|
@ -325,7 +325,7 @@ public class ResultMergerTest {
|
||||||
* SetMerger test
|
* SetMerger test
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testSetMerger() {
|
void testSetMerger() {
|
||||||
Set<Object> set1 = new HashSet<Object>() {{
|
Set<Object> set1 = new HashSet<Object>() {{
|
||||||
add(null);
|
add(null);
|
||||||
add("1");
|
add("1");
|
||||||
|
|
@ -360,7 +360,7 @@ public class ResultMergerTest {
|
||||||
* ShortArrayMerger test
|
* ShortArrayMerger test
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testShortArrayMerger() {
|
void testShortArrayMerger() {
|
||||||
short[] arrayOne = {1, 2};
|
short[] arrayOne = {1, 2};
|
||||||
short[] arrayTwo = {2, 34};
|
short[] arrayTwo = {2, 34};
|
||||||
short[] result = mergerFactory.getMerger(short[].class).merge(arrayOne, arrayTwo, null);
|
short[] result = mergerFactory.getMerger(short[].class).merge(arrayOne, arrayTwo, null);
|
||||||
|
|
@ -381,7 +381,7 @@ public class ResultMergerTest {
|
||||||
* IntSumMerger test
|
* IntSumMerger test
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testIntSumMerger() {
|
void testIntSumMerger() {
|
||||||
Integer[] intArr = IntStream.rangeClosed(1, 100).boxed().toArray(Integer[]::new);
|
Integer[] intArr = IntStream.rangeClosed(1, 100).boxed().toArray(Integer[]::new);
|
||||||
Merger<Integer> merger = ApplicationModel.defaultModel().getExtension(Merger.class, "intsum");
|
Merger<Integer> merger = ApplicationModel.defaultModel().getExtension(Merger.class, "intsum");
|
||||||
Assertions.assertEquals(5050, merger.merge(intArr));
|
Assertions.assertEquals(5050, merger.merge(intArr));
|
||||||
|
|
@ -394,7 +394,7 @@ public class ResultMergerTest {
|
||||||
* DoubleSumMerger test
|
* DoubleSumMerger test
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testDoubleSumMerger() {
|
void testDoubleSumMerger() {
|
||||||
Double[] doubleArr = DoubleStream.iterate(1, v -> ++v).limit(100).boxed().toArray(Double[]::new);
|
Double[] doubleArr = DoubleStream.iterate(1, v -> ++v).limit(100).boxed().toArray(Double[]::new);
|
||||||
Merger<Double> merger = ApplicationModel.defaultModel().getExtension(Merger.class, "doublesum");
|
Merger<Double> merger = ApplicationModel.defaultModel().getExtension(Merger.class, "doublesum");
|
||||||
Assertions.assertEquals(5050, merger.merge(doubleArr));
|
Assertions.assertEquals(5050, merger.merge(doubleArr));
|
||||||
|
|
@ -407,7 +407,7 @@ public class ResultMergerTest {
|
||||||
* FloatSumMerger test
|
* FloatSumMerger test
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testFloatSumMerger() {
|
void testFloatSumMerger() {
|
||||||
Float[] floatArr = Stream.iterate(1.0F, v -> ++v).limit(100).toArray(Float[]::new);
|
Float[] floatArr = Stream.iterate(1.0F, v -> ++v).limit(100).toArray(Float[]::new);
|
||||||
Merger<Float> merger = ApplicationModel.defaultModel().getExtension(Merger.class, "floatsum");
|
Merger<Float> merger = ApplicationModel.defaultModel().getExtension(Merger.class, "floatsum");
|
||||||
Assertions.assertEquals(5050, merger.merge(floatArr));
|
Assertions.assertEquals(5050, merger.merge(floatArr));
|
||||||
|
|
@ -420,7 +420,7 @@ public class ResultMergerTest {
|
||||||
* LongSumMerger test
|
* LongSumMerger test
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testLongSumMerger() {
|
void testLongSumMerger() {
|
||||||
Long[] longArr = LongStream.rangeClosed(1, 100).boxed().toArray(Long[]::new);
|
Long[] longArr = LongStream.rangeClosed(1, 100).boxed().toArray(Long[]::new);
|
||||||
Merger<Long> merger = ApplicationModel.defaultModel().getExtension(Merger.class, "longsum");
|
Merger<Long> merger = ApplicationModel.defaultModel().getExtension(Merger.class, "longsum");
|
||||||
Assertions.assertEquals(5050, merger.merge(longArr));
|
Assertions.assertEquals(5050, merger.merge(longArr));
|
||||||
|
|
@ -433,7 +433,7 @@ public class ResultMergerTest {
|
||||||
* IntFindAnyMerger test
|
* IntFindAnyMerger test
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testIntFindAnyMerger() {
|
void testIntFindAnyMerger() {
|
||||||
Integer[] intArr = {1, 2, 3, 4};
|
Integer[] intArr = {1, 2, 3, 4};
|
||||||
Merger<Integer> merger = ApplicationModel.defaultModel().getExtension(Merger.class, "intany");
|
Merger<Integer> merger = ApplicationModel.defaultModel().getExtension(Merger.class, "intany");
|
||||||
Assertions.assertNotNull(merger.merge(intArr));
|
Assertions.assertNotNull(merger.merge(intArr));
|
||||||
|
|
@ -446,7 +446,7 @@ public class ResultMergerTest {
|
||||||
* IntFindFirstMerger test
|
* IntFindFirstMerger test
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testIntFindFirstMerger() {
|
void testIntFindFirstMerger() {
|
||||||
Integer[] intArr = {1, 2, 3, 4};
|
Integer[] intArr = {1, 2, 3, 4};
|
||||||
Merger<Integer> merger = ApplicationModel.defaultModel().getExtension(Merger.class, "intfirst");
|
Merger<Integer> merger = ApplicationModel.defaultModel().getExtension(Merger.class, "intfirst");
|
||||||
Assertions.assertEquals(1, merger.merge(intArr));
|
Assertions.assertEquals(1, merger.merge(intArr));
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
@Disabled("FIXME This is not a formal UT")
|
@Disabled("FIXME This is not a formal UT")
|
||||||
public class ConfigConditionRouterTest {
|
class ConfigConditionRouterTest {
|
||||||
private static CuratorFramework client;
|
private static CuratorFramework client;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
|
|
@ -35,7 +35,7 @@ public class ConfigConditionRouterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void normalConditionRuleApplicationLevelTest() {
|
void normalConditionRuleApplicationLevelTest() {
|
||||||
String serviceStr = "---\n" +
|
String serviceStr = "---\n" +
|
||||||
"scope: application\n" +
|
"scope: application\n" +
|
||||||
"force: true\n" +
|
"force: true\n" +
|
||||||
|
|
@ -58,7 +58,7 @@ public class ConfigConditionRouterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void normalConditionRuleApplicationServiceLevelTest() {
|
void normalConditionRuleApplicationServiceLevelTest() {
|
||||||
String serviceStr = "---\n" +
|
String serviceStr = "---\n" +
|
||||||
"scope: application\n" +
|
"scope: application\n" +
|
||||||
"force: true\n" +
|
"force: true\n" +
|
||||||
|
|
@ -82,7 +82,7 @@ public class ConfigConditionRouterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void normalConditionRuleServiceLevelTest() {
|
void normalConditionRuleServiceLevelTest() {
|
||||||
String serviceStr = "---\n" +
|
String serviceStr = "---\n" +
|
||||||
"scope: service\n" +
|
"scope: service\n" +
|
||||||
"force: true\n" +
|
"force: true\n" +
|
||||||
|
|
@ -107,7 +107,7 @@ public class ConfigConditionRouterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void abnormalNoruleConditionRuleTest() {
|
void abnormalNoruleConditionRuleTest() {
|
||||||
String serviceStr = "---\n" +
|
String serviceStr = "---\n" +
|
||||||
"scope: service\n" +
|
"scope: service\n" +
|
||||||
"force: true\n" +
|
"force: true\n" +
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,10 @@ import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
public class RouterSnapshotFilterTest {
|
class RouterSnapshotFilterTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
void test() {
|
||||||
FrameworkModel frameworkModel = new FrameworkModel();
|
FrameworkModel frameworkModel = new FrameworkModel();
|
||||||
RouterSnapshotSwitcher routerSnapshotSwitcher = frameworkModel.getBeanFactory().getBean(RouterSnapshotSwitcher.class);
|
RouterSnapshotSwitcher routerSnapshotSwitcher = frameworkModel.getBeanFactory().getBean(RouterSnapshotSwitcher.class);
|
||||||
RouterSnapshotFilter routerSnapshotFilter = new RouterSnapshotFilter(frameworkModel);
|
RouterSnapshotFilter routerSnapshotFilter = new RouterSnapshotFilter(frameworkModel);
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ import java.util.List;
|
||||||
import static org.apache.dubbo.rpc.cluster.Constants.FORCE_KEY;
|
import static org.apache.dubbo.rpc.cluster.Constants.FORCE_KEY;
|
||||||
import static org.apache.dubbo.rpc.cluster.Constants.RULE_KEY;
|
import static org.apache.dubbo.rpc.cluster.Constants.RULE_KEY;
|
||||||
|
|
||||||
public class ConditionStateRouterTest {
|
class ConditionStateRouterTest {
|
||||||
private static final String LOCAL_HOST = "127.0.0.1";
|
private static final String LOCAL_HOST = "127.0.0.1";
|
||||||
private URL SCRIPT_URL = URL.valueOf("condition://0.0.0.0/com.foo.BarService");
|
private URL SCRIPT_URL = URL.valueOf("condition://0.0.0.0/com.foo.BarService");
|
||||||
|
|
||||||
|
|
@ -54,7 +54,7 @@ public class ConditionStateRouterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRoute_matchWhen() {
|
void testRoute_matchWhen() {
|
||||||
Invocation invocation = new RpcInvocation();
|
Invocation invocation = new RpcInvocation();
|
||||||
|
|
||||||
StateRouter router = new ConditionStateRouterFactory().getRouter(String.class, getRouteUrl(" => host = 1.2.3.4"));
|
StateRouter router = new ConditionStateRouterFactory().getRouter(String.class, getRouteUrl(" => host = 1.2.3.4"));
|
||||||
|
|
@ -87,7 +87,7 @@ public class ConditionStateRouterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRoute_matchFilter() {
|
void testRoute_matchFilter() {
|
||||||
List<Invoker<String>> originInvokers = new ArrayList<Invoker<String>>();
|
List<Invoker<String>> originInvokers = new ArrayList<Invoker<String>>();
|
||||||
Invoker<String> invoker1 = new MockInvoker<String>(URL.valueOf(
|
Invoker<String> invoker1 = new MockInvoker<String>(URL.valueOf(
|
||||||
"dubbo://10.20.3.3:20880/com.foo.BarService?serialization=fastjson"));
|
"dubbo://10.20.3.3:20880/com.foo.BarService?serialization=fastjson"));
|
||||||
|
|
@ -139,7 +139,7 @@ public class ConditionStateRouterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRoute_methodRoute() {
|
void testRoute_methodRoute() {
|
||||||
Invocation invocation = new RpcInvocation("getFoo", "com.foo.BarService", "", new Class<?>[0], new Object[0]);
|
Invocation invocation = new RpcInvocation("getFoo", "com.foo.BarService", "", new Class<?>[0], new Object[0]);
|
||||||
// More than one methods, mismatch
|
// More than one methods, mismatch
|
||||||
StateRouter router = new ConditionStateRouterFactory().getRouter(String.class, getRouteUrl("methods=getFoo => host = 1.2.3.4"));
|
StateRouter router = new ConditionStateRouterFactory().getRouter(String.class, getRouteUrl("methods=getFoo => host = 1.2.3.4"));
|
||||||
|
|
@ -191,7 +191,7 @@ public class ConditionStateRouterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRoute_ReturnFalse() {
|
void testRoute_ReturnFalse() {
|
||||||
StateRouter router = new ConditionStateRouterFactory().getRouter(String.class, getRouteUrl("host = " + LOCAL_HOST + " => false"));
|
StateRouter router = new ConditionStateRouterFactory().getRouter(String.class, getRouteUrl("host = " + LOCAL_HOST + " => false"));
|
||||||
List<Invoker<String>> originInvokers = new ArrayList<Invoker<String>>();
|
List<Invoker<String>> originInvokers = new ArrayList<Invoker<String>>();
|
||||||
originInvokers.add(new MockInvoker<String>());
|
originInvokers.add(new MockInvoker<String>());
|
||||||
|
|
@ -204,7 +204,7 @@ public class ConditionStateRouterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRoute_ReturnEmpty() {
|
void testRoute_ReturnEmpty() {
|
||||||
StateRouter router = new ConditionStateRouterFactory().getRouter(String.class, getRouteUrl("host = " + LOCAL_HOST + " => "));
|
StateRouter router = new ConditionStateRouterFactory().getRouter(String.class, getRouteUrl("host = " + LOCAL_HOST + " => "));
|
||||||
List<Invoker<String>> originInvokers = new ArrayList<Invoker<String>>();
|
List<Invoker<String>> originInvokers = new ArrayList<Invoker<String>>();
|
||||||
originInvokers.add(new MockInvoker<String>());
|
originInvokers.add(new MockInvoker<String>());
|
||||||
|
|
@ -217,7 +217,7 @@ public class ConditionStateRouterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRoute_ReturnAll() {
|
void testRoute_ReturnAll() {
|
||||||
StateRouter router = new ConditionStateRouterFactory().getRouter(String.class, getRouteUrl("host = " + LOCAL_HOST + " => " + " host = " + LOCAL_HOST));
|
StateRouter router = new ConditionStateRouterFactory().getRouter(String.class, getRouteUrl("host = " + LOCAL_HOST + " => " + " host = " + LOCAL_HOST));
|
||||||
List<Invoker<String>> originInvokers = new ArrayList<Invoker<String>>();
|
List<Invoker<String>> originInvokers = new ArrayList<Invoker<String>>();
|
||||||
originInvokers.add(new MockInvoker<String>(URL.valueOf("dubbo://" + LOCAL_HOST + ":20880/com.foo.BarService")));
|
originInvokers.add(new MockInvoker<String>(URL.valueOf("dubbo://" + LOCAL_HOST + ":20880/com.foo.BarService")));
|
||||||
|
|
@ -230,7 +230,7 @@ public class ConditionStateRouterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRoute_HostFilter() {
|
void testRoute_HostFilter() {
|
||||||
StateRouter router = new ConditionStateRouterFactory().getRouter(String.class, getRouteUrl("host = " + LOCAL_HOST + " => " + " host = " + LOCAL_HOST));
|
StateRouter router = new ConditionStateRouterFactory().getRouter(String.class, getRouteUrl("host = " + LOCAL_HOST + " => " + " host = " + LOCAL_HOST));
|
||||||
List<Invoker<String>> originInvokers = new ArrayList<Invoker<String>>();
|
List<Invoker<String>> originInvokers = new ArrayList<Invoker<String>>();
|
||||||
Invoker<String> invoker1 = new MockInvoker<String>(URL.valueOf("dubbo://10.20.3.3:20880/com.foo.BarService"));
|
Invoker<String> invoker1 = new MockInvoker<String>(URL.valueOf("dubbo://10.20.3.3:20880/com.foo.BarService"));
|
||||||
|
|
@ -248,7 +248,7 @@ public class ConditionStateRouterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRoute_Empty_HostFilter() {
|
void testRoute_Empty_HostFilter() {
|
||||||
StateRouter router = new ConditionStateRouterFactory().getRouter(String.class, getRouteUrl(" => " + " host = " + LOCAL_HOST));
|
StateRouter router = new ConditionStateRouterFactory().getRouter(String.class, getRouteUrl(" => " + " host = " + LOCAL_HOST));
|
||||||
List<Invoker<String>> originInvokers = new ArrayList<Invoker<String>>();
|
List<Invoker<String>> originInvokers = new ArrayList<Invoker<String>>();
|
||||||
Invoker<String> invoker1 = new MockInvoker<String>(URL.valueOf("dubbo://10.20.3.3:20880/com.foo.BarService"));
|
Invoker<String> invoker1 = new MockInvoker<String>(URL.valueOf("dubbo://10.20.3.3:20880/com.foo.BarService"));
|
||||||
|
|
@ -266,7 +266,7 @@ public class ConditionStateRouterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRoute_False_HostFilter() {
|
void testRoute_False_HostFilter() {
|
||||||
StateRouter router = new ConditionStateRouterFactory().getRouter(String.class, getRouteUrl("true => " + " host = " + LOCAL_HOST));
|
StateRouter router = new ConditionStateRouterFactory().getRouter(String.class, getRouteUrl("true => " + " host = " + LOCAL_HOST));
|
||||||
List<Invoker<String>> originInvokers = new ArrayList<Invoker<String>>();
|
List<Invoker<String>> originInvokers = new ArrayList<Invoker<String>>();
|
||||||
Invoker<String> invoker1 = new MockInvoker<String>(URL.valueOf("dubbo://10.20.3.3:20880/com.foo.BarService"));
|
Invoker<String> invoker1 = new MockInvoker<String>(URL.valueOf("dubbo://10.20.3.3:20880/com.foo.BarService"));
|
||||||
|
|
@ -284,7 +284,7 @@ public class ConditionStateRouterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRoute_Placeholder() {
|
void testRoute_Placeholder() {
|
||||||
StateRouter router = new ConditionStateRouterFactory().getRouter(String.class, getRouteUrl("host = " + LOCAL_HOST + " => " + " host = $host"));
|
StateRouter router = new ConditionStateRouterFactory().getRouter(String.class, getRouteUrl("host = " + LOCAL_HOST + " => " + " host = $host"));
|
||||||
List<Invoker<String>> originInvokers = new ArrayList<Invoker<String>>();
|
List<Invoker<String>> originInvokers = new ArrayList<Invoker<String>>();
|
||||||
Invoker<String> invoker1 = new MockInvoker<String>(URL.valueOf("dubbo://10.20.3.3:20880/com.foo.BarService"));
|
Invoker<String> invoker1 = new MockInvoker<String>(URL.valueOf("dubbo://10.20.3.3:20880/com.foo.BarService"));
|
||||||
|
|
@ -302,7 +302,7 @@ public class ConditionStateRouterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRoute_NoForce() {
|
void testRoute_NoForce() {
|
||||||
StateRouter router = new ConditionStateRouterFactory().getRouter(String.class, getRouteUrl("host = " + LOCAL_HOST + " => " + " host = 1.2.3.4"));
|
StateRouter router = new ConditionStateRouterFactory().getRouter(String.class, getRouteUrl("host = " + LOCAL_HOST + " => " + " host = 1.2.3.4"));
|
||||||
List<Invoker<String>> originInvokers = new ArrayList<Invoker<String>>();
|
List<Invoker<String>> originInvokers = new ArrayList<Invoker<String>>();
|
||||||
Invoker<String> invoker1 = new MockInvoker<String>(URL.valueOf("dubbo://10.20.3.3:20880/com.foo.BarService"));
|
Invoker<String> invoker1 = new MockInvoker<String>(URL.valueOf("dubbo://10.20.3.3:20880/com.foo.BarService"));
|
||||||
|
|
@ -318,7 +318,7 @@ public class ConditionStateRouterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRoute_Force() {
|
void testRoute_Force() {
|
||||||
StateRouter router = new ConditionStateRouterFactory().getRouter(String.class, getRouteUrl("host = " + LOCAL_HOST + " => " + " host = 1.2.3.4").addParameter(FORCE_KEY, String.valueOf(true)));
|
StateRouter router = new ConditionStateRouterFactory().getRouter(String.class, getRouteUrl("host = " + LOCAL_HOST + " => " + " host = 1.2.3.4").addParameter(FORCE_KEY, String.valueOf(true)));
|
||||||
List<Invoker<String>> originInvokers = new ArrayList<Invoker<String>>();
|
List<Invoker<String>> originInvokers = new ArrayList<Invoker<String>>();
|
||||||
Invoker<String> invoker1 = new MockInvoker<String>(URL.valueOf("dubbo://10.20.3.3:20880/com.foo.BarService"));
|
Invoker<String> invoker1 = new MockInvoker<String>(URL.valueOf("dubbo://10.20.3.3:20880/com.foo.BarService"));
|
||||||
|
|
@ -334,7 +334,7 @@ public class ConditionStateRouterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRoute_Arguments() {
|
void testRoute_Arguments() {
|
||||||
StateRouter router = new ConditionStateRouterFactory().getRouter(String.class, getRouteUrl("arguments[0] = a " + " => " + " host = 1.2.3.4").addParameter(FORCE_KEY, String.valueOf(true)));
|
StateRouter router = new ConditionStateRouterFactory().getRouter(String.class, getRouteUrl("arguments[0] = a " + " => " + " host = 1.2.3.4").addParameter(FORCE_KEY, String.valueOf(true)));
|
||||||
List<Invoker<String>> originInvokers = new ArrayList<>();
|
List<Invoker<String>> originInvokers = new ArrayList<>();
|
||||||
Invoker<String> invoker1 = new MockInvoker<>(URL.valueOf("dubbo://10.20.3.3:20880/com.foo.BarService"));
|
Invoker<String> invoker1 = new MockInvoker<>(URL.valueOf("dubbo://10.20.3.3:20880/com.foo.BarService"));
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public class FileRouterEngineTest {
|
class FileRouterEngineTest {
|
||||||
private static boolean isScriptUnsupported = new ScriptEngineManager().getEngineByName("javascript") == null;
|
private static boolean isScriptUnsupported = new ScriptEngineManager().getEngineByName("javascript") == null;
|
||||||
List<Invoker<FileRouterEngineTest>> invokers = new ArrayList<Invoker<FileRouterEngineTest>>();
|
List<Invoker<FileRouterEngineTest>> invokers = new ArrayList<Invoker<FileRouterEngineTest>>();
|
||||||
Invoker<FileRouterEngineTest> invoker1 = mock(Invoker.class);
|
Invoker<FileRouterEngineTest> invoker1 = mock(Invoker.class);
|
||||||
|
|
@ -75,7 +75,7 @@ public class FileRouterEngineTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRouteNotAvailable() {
|
void testRouteNotAvailable() {
|
||||||
if (isScriptUnsupported) return;
|
if (isScriptUnsupported) return;
|
||||||
URL url = initUrl("notAvailablerule.javascript");
|
URL url = initUrl("notAvailablerule.javascript");
|
||||||
initInvocation("method1");
|
initInvocation("method1");
|
||||||
|
|
@ -92,7 +92,7 @@ public class FileRouterEngineTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRouteAvailable() {
|
void testRouteAvailable() {
|
||||||
if (isScriptUnsupported) return;
|
if (isScriptUnsupported) return;
|
||||||
URL url = initUrl("availablerule.javascript");
|
URL url = initUrl("availablerule.javascript");
|
||||||
initInvocation("method1");
|
initInvocation("method1");
|
||||||
|
|
@ -109,7 +109,7 @@ public class FileRouterEngineTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRouteByMethodName() {
|
void testRouteByMethodName() {
|
||||||
if (isScriptUnsupported) return;
|
if (isScriptUnsupported) return;
|
||||||
URL url = initUrl("methodrule.javascript");
|
URL url = initUrl("methodrule.javascript");
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
|
|
||||||
public class MeshAppRuleListenerTest {
|
class MeshAppRuleListenerTest {
|
||||||
|
|
||||||
private final static String rule1 = "apiVersion: service.dubbo.apache.org/v1alpha1\n" +
|
private final static String rule1 = "apiVersion: service.dubbo.apache.org/v1alpha1\n" +
|
||||||
"kind: DestinationRule\n" +
|
"kind: DestinationRule\n" +
|
||||||
|
|
@ -117,7 +117,7 @@ public class MeshAppRuleListenerTest {
|
||||||
" hosts: [demo]\n";
|
" hosts: [demo]\n";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStandard() {
|
void testStandard() {
|
||||||
MeshAppRuleListener meshAppRuleListener = new MeshAppRuleListener("demo-route");
|
MeshAppRuleListener meshAppRuleListener = new MeshAppRuleListener("demo-route");
|
||||||
|
|
||||||
StandardMeshRuleRouter standardMeshRuleRouter = Mockito.spy(new StandardMeshRuleRouter(URL.valueOf("")));
|
StandardMeshRuleRouter standardMeshRuleRouter = Mockito.spy(new StandardMeshRuleRouter(URL.valueOf("")));
|
||||||
|
|
@ -143,7 +143,7 @@ public class MeshAppRuleListenerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void register() {
|
void register() {
|
||||||
MeshAppRuleListener meshAppRuleListener = new MeshAppRuleListener("demo-route");
|
MeshAppRuleListener meshAppRuleListener = new MeshAppRuleListener("demo-route");
|
||||||
|
|
||||||
StandardMeshRuleRouter standardMeshRuleRouter1 = Mockito.spy(new StandardMeshRuleRouter(URL.valueOf("")));
|
StandardMeshRuleRouter standardMeshRuleRouter1 = Mockito.spy(new StandardMeshRuleRouter(URL.valueOf("")));
|
||||||
|
|
@ -180,7 +180,7 @@ public class MeshAppRuleListenerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void unregister() {
|
void unregister() {
|
||||||
MeshAppRuleListener meshAppRuleListener = new MeshAppRuleListener("demo-route");
|
MeshAppRuleListener meshAppRuleListener = new MeshAppRuleListener("demo-route");
|
||||||
|
|
||||||
StandardMeshRuleRouter standardMeshRuleRouter1 = Mockito.spy(new StandardMeshRuleRouter(URL.valueOf("")));
|
StandardMeshRuleRouter standardMeshRuleRouter1 = Mockito.spy(new StandardMeshRuleRouter(URL.valueOf("")));
|
||||||
|
|
@ -201,7 +201,7 @@ public class MeshAppRuleListenerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void process() {
|
void process() {
|
||||||
MeshAppRuleListener meshAppRuleListener = new MeshAppRuleListener("demo-route");
|
MeshAppRuleListener meshAppRuleListener = new MeshAppRuleListener("demo-route");
|
||||||
|
|
||||||
StandardMeshRuleRouter standardMeshRuleRouter = Mockito.spy(new StandardMeshRuleRouter(URL.valueOf("")));
|
StandardMeshRuleRouter standardMeshRuleRouter = Mockito.spy(new StandardMeshRuleRouter(URL.valueOf("")));
|
||||||
|
|
@ -243,7 +243,7 @@ public class MeshAppRuleListenerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnknownRule() {
|
void testUnknownRule() {
|
||||||
MeshAppRuleListener meshAppRuleListener = new MeshAppRuleListener("demo-route");
|
MeshAppRuleListener meshAppRuleListener = new MeshAppRuleListener("demo-route");
|
||||||
|
|
||||||
StandardMeshRuleRouter standardMeshRuleRouter = Mockito.spy(new StandardMeshRuleRouter(URL.valueOf("")));
|
StandardMeshRuleRouter standardMeshRuleRouter = Mockito.spy(new StandardMeshRuleRouter(URL.valueOf("")));
|
||||||
|
|
@ -274,7 +274,7 @@ public class MeshAppRuleListenerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMultipleRule() {
|
void testMultipleRule() {
|
||||||
MeshAppRuleListener meshAppRuleListener = new MeshAppRuleListener("demo-route");
|
MeshAppRuleListener meshAppRuleListener = new MeshAppRuleListener("demo-route");
|
||||||
|
|
||||||
AtomicInteger count = new AtomicInteger(0);
|
AtomicInteger count = new AtomicInteger(0);
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
public class MeshRuleCacheTest {
|
class MeshRuleCacheTest {
|
||||||
|
|
||||||
private Invoker<Object> createInvoker(String app) {
|
private Invoker<Object> createInvoker(String app) {
|
||||||
URL url = URL.valueOf("dubbo://localhost/DemoInterface?" + (StringUtils.isEmpty(app) ? "" : "remote.application=" + app));
|
URL url = URL.valueOf("dubbo://localhost/DemoInterface?" + (StringUtils.isEmpty(app) ? "" : "remote.application=" + app));
|
||||||
|
|
@ -49,7 +49,7 @@ public class MeshRuleCacheTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void containMapKeyValue() {
|
void containMapKeyValue() {
|
||||||
URL url = mock(URL.class);
|
URL url = mock(URL.class);
|
||||||
when(url.getServiceKey()).thenReturn("test");
|
when(url.getServiceKey()).thenReturn("test");
|
||||||
|
|
||||||
|
|
@ -77,7 +77,7 @@ public class MeshRuleCacheTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuild() {
|
void testBuild() {
|
||||||
BitList<Invoker<Object>> invokers = new BitList<>(Arrays.asList(createInvoker(""), createInvoker("unknown"), createInvoker("app1")));
|
BitList<Invoker<Object>> invokers = new BitList<>(Arrays.asList(createInvoker(""), createInvoker("unknown"), createInvoker("app1")));
|
||||||
|
|
||||||
Subset subset = new Subset();
|
Subset subset = new Subset();
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
|
||||||
public class MeshRuleManagerTest {
|
class MeshRuleManagerTest {
|
||||||
private final static String rule1 = "apiVersion: service.dubbo.apache.org/v1alpha1\n" +
|
private final static String rule1 = "apiVersion: service.dubbo.apache.org/v1alpha1\n" +
|
||||||
"kind: DestinationRule\n" +
|
"kind: DestinationRule\n" +
|
||||||
"metadata: { name: demo-route.Type1 }\n" +
|
"metadata: { name: demo-route.Type1 }\n" +
|
||||||
|
|
@ -94,7 +94,7 @@ public class MeshRuleManagerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRegister1() {
|
void testRegister1() {
|
||||||
MeshRuleManager meshRuleManager = new MeshRuleManager(moduleModel);
|
MeshRuleManager meshRuleManager = new MeshRuleManager(moduleModel);
|
||||||
|
|
||||||
MeshRuleListener meshRuleListener1 = new MeshRuleListener() {
|
MeshRuleListener meshRuleListener1 = new MeshRuleListener() {
|
||||||
|
|
@ -158,7 +158,7 @@ public class MeshRuleManagerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRegister2() {
|
void testRegister2() {
|
||||||
MeshRuleManager meshRuleManager = new MeshRuleManager(moduleModel);
|
MeshRuleManager meshRuleManager = new MeshRuleManager(moduleModel);
|
||||||
|
|
||||||
AtomicInteger invokeTimes = new AtomicInteger(0);
|
AtomicInteger invokeTimes = new AtomicInteger(0);
|
||||||
|
|
@ -199,7 +199,7 @@ public class MeshRuleManagerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRegister3() {
|
void testRegister3() {
|
||||||
MeshEnvListenerFactory meshEnvListenerFactory1 = Mockito.mock(MeshEnvListenerFactory.class);
|
MeshEnvListenerFactory meshEnvListenerFactory1 = Mockito.mock(MeshEnvListenerFactory.class);
|
||||||
MeshEnvListenerFactory meshEnvListenerFactory2 = Mockito.mock(MeshEnvListenerFactory.class);
|
MeshEnvListenerFactory meshEnvListenerFactory2 = Mockito.mock(MeshEnvListenerFactory.class);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
|
||||||
public class MeshRuleRouterTest {
|
class MeshRuleRouterTest {
|
||||||
private final static String rule1 = "apiVersion: service.dubbo.apache.org/v1alpha1\n" +
|
private final static String rule1 = "apiVersion: service.dubbo.apache.org/v1alpha1\n" +
|
||||||
"kind: DestinationRule\n" +
|
"kind: DestinationRule\n" +
|
||||||
"metadata: { name: demo-route }\n" +
|
"metadata: { name: demo-route }\n" +
|
||||||
|
|
@ -210,7 +210,7 @@ public class MeshRuleRouterTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNotify() {
|
void testNotify() {
|
||||||
StandardMeshRuleRouter<Object> meshRuleRouter = new StandardMeshRuleRouter<>(url);
|
StandardMeshRuleRouter<Object> meshRuleRouter = new StandardMeshRuleRouter<>(url);
|
||||||
meshRuleRouter.notify(null);
|
meshRuleRouter.notify(null);
|
||||||
assertEquals(0, meshRuleRouter.getRemoteAppName().size());
|
assertEquals(0, meshRuleRouter.getRemoteAppName().size());
|
||||||
|
|
@ -236,7 +236,7 @@ public class MeshRuleRouterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRuleChange() {
|
void testRuleChange() {
|
||||||
StandardMeshRuleRouter<Object> meshRuleRouter = new StandardMeshRuleRouter<>(url);
|
StandardMeshRuleRouter<Object> meshRuleRouter = new StandardMeshRuleRouter<>(url);
|
||||||
|
|
||||||
Yaml yaml = new Yaml(new SafeConstructor());
|
Yaml yaml = new Yaml(new SafeConstructor());
|
||||||
|
|
@ -262,7 +262,7 @@ public class MeshRuleRouterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRoute1() {
|
void testRoute1() {
|
||||||
StandardMeshRuleRouter<Object> meshRuleRouter = new StandardMeshRuleRouter<>(url);
|
StandardMeshRuleRouter<Object> meshRuleRouter = new StandardMeshRuleRouter<>(url);
|
||||||
BitList<Invoker<Object>> invokers = new BitList<>(Arrays.asList(createInvoker(""), createInvoker("unknown"), createInvoker("app1")));
|
BitList<Invoker<Object>> invokers = new BitList<>(Arrays.asList(createInvoker(""), createInvoker("unknown"), createInvoker("app1")));
|
||||||
assertEquals(invokers, meshRuleRouter.route(invokers.clone(), null, null, false, null));
|
assertEquals(invokers, meshRuleRouter.route(invokers.clone(), null, null, false, null));
|
||||||
|
|
@ -272,7 +272,7 @@ public class MeshRuleRouterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRoute2() {
|
void testRoute2() {
|
||||||
StandardMeshRuleRouter<Object> meshRuleRouter = new StandardMeshRuleRouter<>(url);
|
StandardMeshRuleRouter<Object> meshRuleRouter = new StandardMeshRuleRouter<>(url);
|
||||||
|
|
||||||
Yaml yaml = new Yaml(new SafeConstructor());
|
Yaml yaml = new Yaml(new SafeConstructor());
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,10 @@ import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
|
||||||
public class StandardMeshRuleRouterFactoryTest {
|
class StandardMeshRuleRouterFactoryTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getRouter() {
|
void getRouter() {
|
||||||
StandardMeshRuleRouterFactory ruleRouterFactory = new StandardMeshRuleRouterFactory();
|
StandardMeshRuleRouterFactory ruleRouterFactory = new StandardMeshRuleRouterFactory();
|
||||||
Assertions.assertTrue(ruleRouterFactory.getRouter(Object.class, URL.valueOf("")) instanceof StandardMeshRuleRouter);
|
Assertions.assertTrue(ruleRouterFactory.getRouter(Object.class, URL.valueOf("")) instanceof StandardMeshRuleRouter);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,10 +33,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
|
|
||||||
public class DestinationRuleTest {
|
class DestinationRuleTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parserTest() {
|
void parserTest() {
|
||||||
Yaml yaml = new Yaml();
|
Yaml yaml = new Yaml();
|
||||||
DestinationRule destinationRule = yaml.loadAs(this.getClass().getClassLoader().getResourceAsStream("DestinationRuleTest.yaml"), DestinationRule.class);
|
DestinationRule destinationRule = yaml.loadAs(this.getClass().getClassLoader().getResourceAsStream("DestinationRuleTest.yaml"), DestinationRule.class);
|
||||||
|
|
||||||
|
|
@ -84,7 +84,7 @@ public class DestinationRuleTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parserMultiRuleTest() {
|
void parserMultiRuleTest() {
|
||||||
Yaml yaml = new Yaml();
|
Yaml yaml = new Yaml();
|
||||||
Yaml yaml2 = new Yaml();
|
Yaml yaml2 = new Yaml();
|
||||||
Iterable objectIterable = yaml.loadAll(this.getClass().getClassLoader().getResourceAsStream("DestinationRuleTest2.yaml"));
|
Iterable objectIterable = yaml.loadAll(this.getClass().getClassLoader().getResourceAsStream("DestinationRuleTest2.yaml"));
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,10 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
|
|
||||||
public class VirtualServiceRuleTest {
|
class VirtualServiceRuleTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parserTest() {
|
void parserTest() {
|
||||||
Yaml yaml = new Yaml();
|
Yaml yaml = new Yaml();
|
||||||
VirtualServiceRule virtualServiceRule = yaml.loadAs(this.getClass().getClassLoader().getResourceAsStream("VirtualServiceTest.yaml"), VirtualServiceRule.class);
|
VirtualServiceRule virtualServiceRule = yaml.loadAs(this.getClass().getClassLoader().getResourceAsStream("VirtualServiceTest.yaml"), VirtualServiceRule.class);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,10 +33,10 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
|
||||||
public class DubboMatchRequestTest {
|
class DubboMatchRequestTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isMatch() {
|
void isMatch() {
|
||||||
DubboMatchRequest dubboMatchRequest = new DubboMatchRequest();
|
DubboMatchRequest dubboMatchRequest = new DubboMatchRequest();
|
||||||
|
|
||||||
// methodMatch
|
// methodMatch
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,10 @@ import org.junit.jupiter.api.Test;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class BoolMatchTest {
|
class BoolMatchTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isMatch() {
|
void isMatch() {
|
||||||
BoolMatch boolMatch = new BoolMatch();
|
BoolMatch boolMatch = new BoolMatch();
|
||||||
boolMatch.setExact(true);
|
boolMatch.setExact(true);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,10 @@ import org.junit.jupiter.api.Test;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class DoubleMatchTest {
|
class DoubleMatchTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void exactMatch() {
|
void exactMatch() {
|
||||||
DoubleMatch doubleMatch = new DoubleMatch();
|
DoubleMatch doubleMatch = new DoubleMatch();
|
||||||
doubleMatch.setExact(10.0);
|
doubleMatch.setExact(10.0);
|
||||||
|
|
||||||
|
|
@ -35,7 +35,7 @@ public class DoubleMatchTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void rangeStartMatch() {
|
void rangeStartMatch() {
|
||||||
DoubleMatch doubleMatch = new DoubleMatch();
|
DoubleMatch doubleMatch = new DoubleMatch();
|
||||||
|
|
||||||
DoubleRangeMatch doubleRangeMatch = new DoubleRangeMatch();
|
DoubleRangeMatch doubleRangeMatch = new DoubleRangeMatch();
|
||||||
|
|
@ -49,7 +49,7 @@ public class DoubleMatchTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void rangeEndMatch() {
|
void rangeEndMatch() {
|
||||||
DoubleMatch doubleMatch = new DoubleMatch();
|
DoubleMatch doubleMatch = new DoubleMatch();
|
||||||
|
|
||||||
DoubleRangeMatch doubleRangeMatch = new DoubleRangeMatch();
|
DoubleRangeMatch doubleRangeMatch = new DoubleRangeMatch();
|
||||||
|
|
@ -63,7 +63,7 @@ public class DoubleMatchTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void rangeStartEndMatch() {
|
void rangeStartEndMatch() {
|
||||||
DoubleMatch doubleMatch = new DoubleMatch();
|
DoubleMatch doubleMatch = new DoubleMatch();
|
||||||
|
|
||||||
DoubleRangeMatch doubleRangeMatch = new DoubleRangeMatch();
|
DoubleRangeMatch doubleRangeMatch = new DoubleRangeMatch();
|
||||||
|
|
@ -83,7 +83,7 @@ public class DoubleMatchTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void modMatch() {
|
void modMatch() {
|
||||||
DoubleMatch doubleMatch = new DoubleMatch();
|
DoubleMatch doubleMatch = new DoubleMatch();
|
||||||
|
|
||||||
doubleMatch.setMod(2.0);
|
doubleMatch.setMod(2.0);
|
||||||
|
|
|
||||||
|
|
@ -33,10 +33,10 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
|
||||||
public class DubboAttachmentMatchTest {
|
class DubboAttachmentMatchTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void dubboContextMatch() {
|
void dubboContextMatch() {
|
||||||
DubboAttachmentMatch dubboAttachmentMatch = new DubboAttachmentMatch();
|
DubboAttachmentMatch dubboAttachmentMatch = new DubboAttachmentMatch();
|
||||||
|
|
||||||
Map<String, StringMatch> dubbocontextMatchMap = new HashMap<>();
|
Map<String, StringMatch> dubbocontextMatchMap = new HashMap<>();
|
||||||
|
|
@ -87,7 +87,7 @@ public class DubboAttachmentMatchTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void tracingContextMatch() {
|
void tracingContextMatch() {
|
||||||
DubboAttachmentMatch dubboAttachmentMatch = new DubboAttachmentMatch();
|
DubboAttachmentMatch dubboAttachmentMatch = new DubboAttachmentMatch();
|
||||||
|
|
||||||
Map<String, StringMatch> tracingContextMatchMap = new HashMap<>();
|
Map<String, StringMatch> tracingContextMatchMap = new HashMap<>();
|
||||||
|
|
@ -130,7 +130,7 @@ public class DubboAttachmentMatchTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contextMatch() {
|
void contextMatch() {
|
||||||
DubboAttachmentMatch dubboAttachmentMatch = new DubboAttachmentMatch();
|
DubboAttachmentMatch dubboAttachmentMatch = new DubboAttachmentMatch();
|
||||||
|
|
||||||
Map<String, StringMatch> tracingContextMatchMap = new HashMap<>();
|
Map<String, StringMatch> tracingContextMatchMap = new HashMap<>();
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,10 @@ import java.util.List;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class DubboMethodMatchTest {
|
class DubboMethodMatchTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void nameMatch() {
|
void nameMatch() {
|
||||||
DubboMethodMatch dubboMethodMatch = new DubboMethodMatch();
|
DubboMethodMatch dubboMethodMatch = new DubboMethodMatch();
|
||||||
|
|
||||||
StringMatch nameStringMatch = new StringMatch();
|
StringMatch nameStringMatch = new StringMatch();
|
||||||
|
|
@ -44,7 +44,7 @@ public class DubboMethodMatchTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void argcMatch() {
|
void argcMatch() {
|
||||||
DubboMethodMatch dubboMethodMatch = new DubboMethodMatch();
|
DubboMethodMatch dubboMethodMatch = new DubboMethodMatch();
|
||||||
dubboMethodMatch.setArgc(1);
|
dubboMethodMatch.setArgc(1);
|
||||||
|
|
||||||
|
|
@ -53,7 +53,7 @@ public class DubboMethodMatchTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void argpMatch() {
|
void argpMatch() {
|
||||||
DubboMethodMatch dubboMethodMatch = new DubboMethodMatch();
|
DubboMethodMatch dubboMethodMatch = new DubboMethodMatch();
|
||||||
|
|
||||||
List<StringMatch> argpMatch = new ArrayList<>();
|
List<StringMatch> argpMatch = new ArrayList<>();
|
||||||
|
|
@ -76,7 +76,7 @@ public class DubboMethodMatchTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parametersMatch() {
|
void parametersMatch() {
|
||||||
|
|
||||||
DubboMethodMatch dubboMethodMatch = new DubboMethodMatch();
|
DubboMethodMatch dubboMethodMatch = new DubboMethodMatch();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,10 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
|
||||||
public class ListBoolMatchTest {
|
class ListBoolMatchTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isMatch() {
|
void isMatch() {
|
||||||
ListBoolMatch listBoolMatch = new ListBoolMatch();
|
ListBoolMatch listBoolMatch = new ListBoolMatch();
|
||||||
List<BoolMatch> oneof = new ArrayList<>();
|
List<BoolMatch> oneof = new ArrayList<>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,10 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
|
||||||
public class ListDoubleMatchTest {
|
class ListDoubleMatchTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isMatch() {
|
void isMatch() {
|
||||||
ListDoubleMatch listDoubleMatch = new ListDoubleMatch();
|
ListDoubleMatch listDoubleMatch = new ListDoubleMatch();
|
||||||
List<DoubleMatch> oneof = new ArrayList<>();
|
List<DoubleMatch> oneof = new ArrayList<>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,10 @@ import java.util.List;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class ListStringMatchTest {
|
class ListStringMatchTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isMatch() {
|
void isMatch() {
|
||||||
ListStringMatch listStringMatch = new ListStringMatch();
|
ListStringMatch listStringMatch = new ListStringMatch();
|
||||||
|
|
||||||
List<StringMatch> oneof = new ArrayList<>();
|
List<StringMatch> oneof = new ArrayList<>();
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,10 @@ import org.junit.jupiter.api.Test;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class StringMatchTest {
|
class StringMatchTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void exactMatch() {
|
void exactMatch() {
|
||||||
StringMatch stringMatch = new StringMatch();
|
StringMatch stringMatch = new StringMatch();
|
||||||
stringMatch.setExact("qinliujie");
|
stringMatch.setExact("qinliujie");
|
||||||
|
|
||||||
|
|
@ -37,7 +37,7 @@ public class StringMatchTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void prefixMatch() {
|
void prefixMatch() {
|
||||||
StringMatch stringMatch = new StringMatch();
|
StringMatch stringMatch = new StringMatch();
|
||||||
stringMatch.setPrefix("org.apache.dubbo.rpc.cluster.router.mesh");
|
stringMatch.setPrefix("org.apache.dubbo.rpc.cluster.router.mesh");
|
||||||
|
|
||||||
|
|
@ -48,7 +48,7 @@ public class StringMatchTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void regxMatch() {
|
void regxMatch() {
|
||||||
StringMatch stringMatch = new StringMatch();
|
StringMatch stringMatch = new StringMatch();
|
||||||
stringMatch.setRegex("org.apache.dubbo.rpc.cluster.router.mesh.*");
|
stringMatch.setRegex("org.apache.dubbo.rpc.cluster.router.mesh.*");
|
||||||
|
|
||||||
|
|
@ -60,7 +60,7 @@ public class StringMatchTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void emptyMatch() {
|
void emptyMatch() {
|
||||||
StringMatch stringMatch = new StringMatch();
|
StringMatch stringMatch = new StringMatch();
|
||||||
stringMatch.setEmpty("empty");
|
stringMatch.setEmpty("empty");
|
||||||
|
|
||||||
|
|
@ -70,7 +70,7 @@ public class StringMatchTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void noEmptyMatch() {
|
void noEmptyMatch() {
|
||||||
StringMatch stringMatch = new StringMatch();
|
StringMatch stringMatch = new StringMatch();
|
||||||
stringMatch.setNoempty("noempty");
|
stringMatch.setNoempty("noempty");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||||
class MeshRuleDispatcherTest {
|
class MeshRuleDispatcherTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void post() {
|
void post() {
|
||||||
MeshRuleDispatcher meshRuleDispatcher = new MeshRuleDispatcher("TestApp");
|
MeshRuleDispatcher meshRuleDispatcher = new MeshRuleDispatcher("TestApp");
|
||||||
|
|
||||||
Map<String, List<Map<String, Object>>> ruleMap = new HashMap<>();
|
Map<String, List<Map<String, Object>>> ruleMap = new HashMap<>();
|
||||||
|
|
@ -107,7 +107,7 @@ class MeshRuleDispatcherTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void register() {
|
void register() {
|
||||||
MeshRuleDispatcher meshRuleDispatcher = new MeshRuleDispatcher("TestApp");
|
MeshRuleDispatcher meshRuleDispatcher = new MeshRuleDispatcher("TestApp");
|
||||||
|
|
||||||
MeshRuleListener listener1 = new MeshRuleListener() {
|
MeshRuleListener listener1 = new MeshRuleListener() {
|
||||||
|
|
@ -134,7 +134,7 @@ class MeshRuleDispatcherTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void unregister() {
|
void unregister() {
|
||||||
MeshRuleDispatcher meshRuleDispatcher = new MeshRuleDispatcher("TestApp");
|
MeshRuleDispatcher meshRuleDispatcher = new MeshRuleDispatcher("TestApp");
|
||||||
|
|
||||||
MeshRuleListener listener1 = new MeshRuleListener() {
|
MeshRuleListener listener1 = new MeshRuleListener() {
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,9 @@ import java.util.List;
|
||||||
|
|
||||||
import static org.apache.dubbo.rpc.cluster.Constants.INVOCATION_NEED_MOCK;
|
import static org.apache.dubbo.rpc.cluster.Constants.INVOCATION_NEED_MOCK;
|
||||||
|
|
||||||
public class MockInvokersSelectorTest {
|
class MockInvokersSelectorTest {
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
void test() {
|
||||||
|
|
||||||
MockInvokersSelector selector = new MockInvokersSelector(URL.valueOf(""));
|
MockInvokersSelector selector = new MockInvokersSelector(URL.valueOf(""));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ import java.util.List;
|
||||||
import static org.apache.dubbo.rpc.cluster.Constants.RULE_KEY;
|
import static org.apache.dubbo.rpc.cluster.Constants.RULE_KEY;
|
||||||
|
|
||||||
@DisabledForJreRange(min = JRE.JAVA_16)
|
@DisabledForJreRange(min = JRE.JAVA_16)
|
||||||
public class ScriptStateRouterTest {
|
class ScriptStateRouterTest {
|
||||||
|
|
||||||
private URL SCRIPT_URL = URL.valueOf("script://javascript?type=javascript");
|
private URL SCRIPT_URL = URL.valueOf("script://javascript?type=javascript");
|
||||||
|
|
||||||
|
|
@ -55,7 +55,7 @@ public class ScriptStateRouterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRouteReturnAll() {
|
void testRouteReturnAll() {
|
||||||
StateRouter router = new ScriptStateRouterFactory().getRouter(String.class, getRouteUrl("function route(op1,op2){return op1} route(invokers)"));
|
StateRouter router = new ScriptStateRouterFactory().getRouter(String.class, getRouteUrl("function route(op1,op2){return op1} route(invokers)"));
|
||||||
List<Invoker<String>> originInvokers = new ArrayList<Invoker<String>>();
|
List<Invoker<String>> originInvokers = new ArrayList<Invoker<String>>();
|
||||||
originInvokers.add(new MockInvoker<String>());
|
originInvokers.add(new MockInvoker<String>());
|
||||||
|
|
@ -68,7 +68,7 @@ public class ScriptStateRouterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRoutePickInvokers() {
|
void testRoutePickInvokers() {
|
||||||
String rule = "var result = new java.util.ArrayList(invokers.size());" +
|
String rule = "var result = new java.util.ArrayList(invokers.size());" +
|
||||||
"for (i=0;i<invokers.size(); i++){ " +
|
"for (i=0;i<invokers.size(); i++){ " +
|
||||||
"if (invokers.get(i).isAvailable()) {" +
|
"if (invokers.get(i).isAvailable()) {" +
|
||||||
|
|
@ -95,7 +95,7 @@ public class ScriptStateRouterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRouteHostFilter() {
|
void testRouteHostFilter() {
|
||||||
List<Invoker<String>> originInvokers = new ArrayList<Invoker<String>>();
|
List<Invoker<String>> originInvokers = new ArrayList<Invoker<String>>();
|
||||||
MockInvoker<String> invoker1 = new MockInvoker<String>(URL.valueOf("dubbo://10.134.108.1:20880/com.dubbo.HelloService"));
|
MockInvoker<String> invoker1 = new MockInvoker<String>(URL.valueOf("dubbo://10.134.108.1:20880/com.dubbo.HelloService"));
|
||||||
MockInvoker<String> invoker2 = new MockInvoker<String>(URL.valueOf("dubbo://10.134.108.2:20880/com.dubbo.HelloService"));
|
MockInvoker<String> invoker2 = new MockInvoker<String>(URL.valueOf("dubbo://10.134.108.2:20880/com.dubbo.HelloService"));
|
||||||
|
|
@ -125,7 +125,7 @@ public class ScriptStateRouterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRoute_throwException() {
|
void testRoute_throwException() {
|
||||||
List<Invoker<String>> originInvokers = new ArrayList<Invoker<String>>();
|
List<Invoker<String>> originInvokers = new ArrayList<Invoker<String>>();
|
||||||
MockInvoker<String> invoker1 = new MockInvoker<String>(URL.valueOf("dubbo://10.134.108.1:20880/com.dubbo.HelloService"));
|
MockInvoker<String> invoker1 = new MockInvoker<String>(URL.valueOf("dubbo://10.134.108.1:20880/com.dubbo.HelloService"));
|
||||||
MockInvoker<String> invoker2 = new MockInvoker<String>(URL.valueOf("dubbo://10.134.108.2:20880/com.dubbo.HelloService"));
|
MockInvoker<String> invoker2 = new MockInvoker<String>(URL.valueOf("dubbo://10.134.108.2:20880/com.dubbo.HelloService"));
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package org.apache.dubbo.rpc.cluster.router.state;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.params.provider.ValueSource;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
@ -26,9 +27,9 @@ import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
|
|
||||||
public class BitListTest {
|
class BitListTest {
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
void test() {
|
||||||
List<String> list = Arrays.asList("A", "B", "C");
|
List<String> list = Arrays.asList("A", "B", "C");
|
||||||
BitList<String> bitList = new BitList<>(list);
|
BitList<String> bitList = new BitList<>(list);
|
||||||
Assertions.assertEquals(bitList.getOriginList(), list);
|
Assertions.assertEquals(bitList.getOriginList(), list);
|
||||||
|
|
@ -57,12 +58,12 @@ public class BitListTest {
|
||||||
|
|
||||||
Object[] newObjects = new Object[1];
|
Object[] newObjects = new Object[1];
|
||||||
Object[] copiedList = bitList.toArray(newObjects);
|
Object[] copiedList = bitList.toArray(newObjects);
|
||||||
Assertions.assertEquals(copiedList.length, 3);
|
Assertions.assertEquals(3, copiedList.length);
|
||||||
Assertions.assertArrayEquals(copiedList, list.toArray());
|
Assertions.assertArrayEquals(copiedList, list.toArray());
|
||||||
|
|
||||||
newObjects = new Object[10];
|
newObjects = new Object[10];
|
||||||
copiedList = bitList.toArray(newObjects);
|
copiedList = bitList.toArray(newObjects);
|
||||||
Assertions.assertEquals(copiedList.length, 10);
|
Assertions.assertEquals(10, copiedList.length);
|
||||||
Assertions.assertEquals("A", copiedList[0]);
|
Assertions.assertEquals("A", copiedList[0]);
|
||||||
Assertions.assertEquals("B", copiedList[1]);
|
Assertions.assertEquals("B", copiedList[1]);
|
||||||
Assertions.assertEquals("C", copiedList[2]);
|
Assertions.assertEquals("C", copiedList[2]);
|
||||||
|
|
@ -78,7 +79,7 @@ public class BitListTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIntersect() {
|
void testIntersect() {
|
||||||
List<String> aList = Arrays.asList("A", "B", "C");
|
List<String> aList = Arrays.asList("A", "B", "C");
|
||||||
List<String> bList = Arrays.asList("A", "B");
|
List<String> bList = Arrays.asList("A", "B");
|
||||||
List<String> totalList = Arrays.asList("A", "B", "C");
|
List<String> totalList = Arrays.asList("A", "B", "C");
|
||||||
|
|
@ -87,20 +88,20 @@ public class BitListTest {
|
||||||
BitList<String> bBitList = new BitList<>(bList);
|
BitList<String> bBitList = new BitList<>(bList);
|
||||||
|
|
||||||
BitList<String> intersectBitList = aBitList.and(bBitList);
|
BitList<String> intersectBitList = aBitList.and(bBitList);
|
||||||
Assertions.assertEquals(intersectBitList.size(), 2);
|
Assertions.assertEquals(2, intersectBitList.size());
|
||||||
Assertions.assertEquals(intersectBitList.get(0), totalList.get(0));
|
Assertions.assertEquals(totalList.get(0), intersectBitList.get(0));
|
||||||
Assertions.assertEquals(intersectBitList.get(1), totalList.get(1));
|
Assertions.assertEquals(totalList.get(1), intersectBitList.get(1));
|
||||||
|
|
||||||
aBitList.add("D");
|
aBitList.add("D");
|
||||||
intersectBitList = aBitList.and(bBitList);
|
intersectBitList = aBitList.and(bBitList);
|
||||||
Assertions.assertEquals(intersectBitList.size(), 3);
|
Assertions.assertEquals(3, intersectBitList.size());
|
||||||
Assertions.assertEquals(intersectBitList.get(0), totalList.get(0));
|
Assertions.assertEquals(totalList.get(0), intersectBitList.get(0));
|
||||||
Assertions.assertEquals(intersectBitList.get(1), totalList.get(1));
|
Assertions.assertEquals(totalList.get(1), intersectBitList.get(1));
|
||||||
Assertions.assertEquals("D", intersectBitList.get(2));
|
Assertions.assertEquals("D", intersectBitList.get(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsEmpty() {
|
void testIsEmpty() {
|
||||||
List<String> list = Arrays.asList("A", "B", "C");
|
List<String> list = Arrays.asList("A", "B", "C");
|
||||||
BitList<String> bitList = new BitList<>(list);
|
BitList<String> bitList = new BitList<>(list);
|
||||||
bitList.add("D");
|
bitList.add("D");
|
||||||
|
|
@ -113,7 +114,7 @@ public class BitListTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAdd() {
|
void testAdd() {
|
||||||
List<String> list = Arrays.asList("A", "B", "C");
|
List<String> list = Arrays.asList("A", "B", "C");
|
||||||
BitList<String> bitList = new BitList<>(list);
|
BitList<String> bitList = new BitList<>(list);
|
||||||
|
|
||||||
|
|
@ -138,7 +139,7 @@ public class BitListTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddAll() {
|
void testAddAll() {
|
||||||
List<String> list = Arrays.asList("A", "B", "C");
|
List<String> list = Arrays.asList("A", "B", "C");
|
||||||
BitList<String> bitList1 = new BitList<>(list);
|
BitList<String> bitList1 = new BitList<>(list);
|
||||||
BitList<String> bitList2 = new BitList<>(list);
|
BitList<String> bitList2 = new BitList<>(list);
|
||||||
|
|
@ -158,7 +159,7 @@ public class BitListTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGet() {
|
void testGet() {
|
||||||
List<String> list = Arrays.asList("A", "B", "C");
|
List<String> list = Arrays.asList("A", "B", "C");
|
||||||
BitList<String> bitList = new BitList<>(list);
|
BitList<String> bitList = new BitList<>(list);
|
||||||
|
|
||||||
|
|
@ -178,7 +179,7 @@ public class BitListTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRemove() {
|
void testRemove() {
|
||||||
List<String> list = Arrays.asList("A", "B", "C");
|
List<String> list = Arrays.asList("A", "B", "C");
|
||||||
BitList<String> bitList = new BitList<>(list);
|
BitList<String> bitList = new BitList<>(list);
|
||||||
|
|
||||||
|
|
@ -210,7 +211,7 @@ public class BitListTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRemoveIndex() {
|
void testRemoveIndex() {
|
||||||
List<String> list = Arrays.asList("A", "B", "C");
|
List<String> list = Arrays.asList("A", "B", "C");
|
||||||
BitList<String> bitList = new BitList<>(list);
|
BitList<String> bitList = new BitList<>(list);
|
||||||
|
|
||||||
|
|
@ -240,7 +241,7 @@ public class BitListTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRetain() {
|
void testRetain() {
|
||||||
List<String> list = Arrays.asList("A", "B", "C");
|
List<String> list = Arrays.asList("A", "B", "C");
|
||||||
BitList<String> bitList = new BitList<>(list);
|
BitList<String> bitList = new BitList<>(list);
|
||||||
|
|
||||||
|
|
@ -264,7 +265,7 @@ public class BitListTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIndex() {
|
void testIndex() {
|
||||||
List<String> list = Arrays.asList("A", "B", "A");
|
List<String> list = Arrays.asList("A", "B", "A");
|
||||||
BitList<String> bitList = new BitList<>(list);
|
BitList<String> bitList = new BitList<>(list);
|
||||||
|
|
||||||
|
|
@ -286,7 +287,7 @@ public class BitListTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSubList() {
|
void testSubList() {
|
||||||
List<String> list = Arrays.asList("A", "B", "C", "D", "E");
|
List<String> list = Arrays.asList("A", "B", "C", "D", "E");
|
||||||
BitList<String> bitList = new BitList<>(list);
|
BitList<String> bitList = new BitList<>(list);
|
||||||
bitList.addAll(Arrays.asList("F", "G", "H", "I"));
|
bitList.addAll(Arrays.asList("F", "G", "H", "I"));
|
||||||
|
|
@ -333,7 +334,7 @@ public class BitListTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListIterator1() {
|
void testListIterator1() {
|
||||||
List<String> list = Arrays.asList("A", "B", "C", "D", "E");
|
List<String> list = Arrays.asList("A", "B", "C", "D", "E");
|
||||||
BitList<String> bitList = new BitList<>(list);
|
BitList<String> bitList = new BitList<>(list);
|
||||||
|
|
||||||
|
|
@ -352,7 +353,8 @@ public class BitListTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListIterator2() {
|
@ValueSource(ints = {2, })
|
||||||
|
void testListIterator2() {
|
||||||
List<String> list = Arrays.asList("A", "B", "C", "D", "E");
|
List<String> list = Arrays.asList("A", "B", "C", "D", "E");
|
||||||
BitList<String> bitList = new BitList<>(list);
|
BitList<String> bitList = new BitList<>(list);
|
||||||
bitList.addAll(Arrays.asList("F", "G", "H", "I"));
|
bitList.addAll(Arrays.asList("F", "G", "H", "I"));
|
||||||
|
|
@ -373,7 +375,7 @@ public class BitListTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListIterator3() {
|
void testListIterator3() {
|
||||||
List<String> list = Arrays.asList("A", "B", "C", "D", "E");
|
List<String> list = Arrays.asList("A", "B", "C", "D", "E");
|
||||||
BitList<String> bitList = new BitList<>(list);
|
BitList<String> bitList = new BitList<>(list);
|
||||||
bitList.addAll(Arrays.asList("F", "G", "H", "I"));
|
bitList.addAll(Arrays.asList("F", "G", "H", "I"));
|
||||||
|
|
@ -394,7 +396,7 @@ public class BitListTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListIterator4() {
|
void testListIterator4() {
|
||||||
List<String> list = Arrays.asList("A", "B", "C", "D", "E");
|
List<String> list = Arrays.asList("A", "B", "C", "D", "E");
|
||||||
BitList<String> bitList = new BitList<>(list);
|
BitList<String> bitList = new BitList<>(list);
|
||||||
bitList.addAll(Arrays.asList("F", "G", "H", "I"));
|
bitList.addAll(Arrays.asList("F", "G", "H", "I"));
|
||||||
|
|
@ -415,7 +417,7 @@ public class BitListTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListIterator5() {
|
void testListIterator5() {
|
||||||
List<String> list = Arrays.asList("A", "B", "C", "D", "E");
|
List<String> list = Arrays.asList("A", "B", "C", "D", "E");
|
||||||
BitList<String> bitList = new BitList<>(list);
|
BitList<String> bitList = new BitList<>(list);
|
||||||
bitList.addAll(Arrays.asList("F", "G", "H", "I"));
|
bitList.addAll(Arrays.asList("F", "G", "H", "I"));
|
||||||
|
|
@ -445,7 +447,7 @@ public class BitListTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListIterator6() {
|
void testListIterator6() {
|
||||||
List<String> list = Arrays.asList("A", "B", "C", "D", "E");
|
List<String> list = Arrays.asList("A", "B", "C", "D", "E");
|
||||||
BitList<String> bitList = new BitList<>(list);
|
BitList<String> bitList = new BitList<>(list);
|
||||||
bitList.addAll(Arrays.asList("F", "G", "H", "I"));
|
bitList.addAll(Arrays.asList("F", "G", "H", "I"));
|
||||||
|
|
@ -474,7 +476,7 @@ public class BitListTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListIterator7() {
|
void testListIterator7() {
|
||||||
List<String> list = Arrays.asList("A", "B", "C", "D", "E");
|
List<String> list = Arrays.asList("A", "B", "C", "D", "E");
|
||||||
BitList<String> bitList = new BitList<>(list);
|
BitList<String> bitList = new BitList<>(list);
|
||||||
bitList.addAll(Arrays.asList("F", "G", "H", "I"));
|
bitList.addAll(Arrays.asList("F", "G", "H", "I"));
|
||||||
|
|
@ -503,7 +505,7 @@ public class BitListTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListIterator8() {
|
void testListIterator8() {
|
||||||
List<String> list = Arrays.asList("A", "B", "C", "D", "E");
|
List<String> list = Arrays.asList("A", "B", "C", "D", "E");
|
||||||
BitList<String> bitList = new BitList<>(list);
|
BitList<String> bitList = new BitList<>(list);
|
||||||
bitList.addAll(Arrays.asList("F", "G", "H", "I"));
|
bitList.addAll(Arrays.asList("F", "G", "H", "I"));
|
||||||
|
|
@ -532,7 +534,7 @@ public class BitListTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testClone1() {
|
void testClone1() {
|
||||||
List<String> list = Arrays.asList("A", "B", "C", "D", "E");
|
List<String> list = Arrays.asList("A", "B", "C", "D", "E");
|
||||||
BitList<String> bitList = new BitList<>(list);
|
BitList<String> bitList = new BitList<>(list);
|
||||||
|
|
||||||
|
|
@ -553,7 +555,7 @@ public class BitListTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testClone2() {
|
void testClone2() {
|
||||||
List<String> list = Arrays.asList("A", "B", "C", "D", "E");
|
List<String> list = Arrays.asList("A", "B", "C", "D", "E");
|
||||||
BitList<String> bitList = new BitList<>(list);
|
BitList<String> bitList = new BitList<>(list);
|
||||||
bitList.addAll(Arrays.asList("F", "G"));
|
bitList.addAll(Arrays.asList("F", "G"));
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ import java.util.Set;
|
||||||
import static org.apache.dubbo.common.constants.CommonConstants.TAG_KEY;
|
import static org.apache.dubbo.common.constants.CommonConstants.TAG_KEY;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
public class TagStateRouterTest {
|
class TagStateRouterTest {
|
||||||
private URL url;
|
private URL url;
|
||||||
private ModuleModel originModel;
|
private ModuleModel originModel;
|
||||||
private ModuleModel moduleModel;
|
private ModuleModel moduleModel;
|
||||||
|
|
@ -71,7 +71,7 @@ public class TagStateRouterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTagRoutePickInvokers() {
|
void testTagRoutePickInvokers() {
|
||||||
StateRouter router = new TagStateRouterFactory().getRouter(TagRouterRule.class, url);
|
StateRouter router = new TagStateRouterFactory().getRouter(TagRouterRule.class, url);
|
||||||
|
|
||||||
List<Invoker<String>> originInvokers = new ArrayList<>();
|
List<Invoker<String>> originInvokers = new ArrayList<>();
|
||||||
|
|
@ -103,7 +103,7 @@ public class TagStateRouterTest {
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void tagRouterRuleParseTest() {
|
void tagRouterRuleParseTest() {
|
||||||
String tagRouterRuleConfig = "---\n" +
|
String tagRouterRuleConfig = "---\n" +
|
||||||
"force: false\n" +
|
"force: false\n" +
|
||||||
"runtime: true\n" +
|
"runtime: true\n" +
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ import static org.mockito.Mockito.when;
|
||||||
* AbstractClusterInvokerTest
|
* AbstractClusterInvokerTest
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public class AbstractClusterInvokerTest {
|
class AbstractClusterInvokerTest {
|
||||||
List<Invoker<IHelloService>> invokers = new ArrayList<Invoker<IHelloService>>();
|
List<Invoker<IHelloService>> invokers = new ArrayList<Invoker<IHelloService>>();
|
||||||
List<Invoker<IHelloService>> selectedInvokers = new ArrayList<Invoker<IHelloService>>();
|
List<Invoker<IHelloService>> selectedInvokers = new ArrayList<Invoker<IHelloService>>();
|
||||||
AbstractClusterInvoker<IHelloService> cluster;
|
AbstractClusterInvoker<IHelloService> cluster;
|
||||||
|
|
@ -165,7 +165,7 @@ public class AbstractClusterInvokerTest {
|
||||||
|
|
||||||
@Disabled("RpcContext attachments will be set to Invocation twice, first in ConsumerContextFilter, second AbstractInvoker")
|
@Disabled("RpcContext attachments will be set to Invocation twice, first in ConsumerContextFilter, second AbstractInvoker")
|
||||||
@Test
|
@Test
|
||||||
public void testBindingAttachment() {
|
void testBindingAttachment() {
|
||||||
final String attachKey = "attach";
|
final String attachKey = "attach";
|
||||||
final String attachValue = "value";
|
final String attachValue = "value";
|
||||||
|
|
||||||
|
|
@ -191,7 +191,7 @@ public class AbstractClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSelect_Invokersize0() throws Exception {
|
void testSelect_Invokersize0() throws Exception {
|
||||||
LoadBalance l = cluster.initLoadBalance(invokers, invocation);
|
LoadBalance l = cluster.initLoadBalance(invokers, invocation);
|
||||||
Assertions.assertNotNull(l,"cluster.initLoadBalance returns null!");
|
Assertions.assertNotNull(l,"cluster.initLoadBalance returns null!");
|
||||||
{
|
{
|
||||||
|
|
@ -207,7 +207,7 @@ public class AbstractClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSelect_Invokersize1() throws Exception {
|
void testSelect_Invokersize1() throws Exception {
|
||||||
invokers.clear();
|
invokers.clear();
|
||||||
invokers.add(invoker1);
|
invokers.add(invoker1);
|
||||||
LoadBalance l = cluster.initLoadBalance(invokers, invocation);
|
LoadBalance l = cluster.initLoadBalance(invokers, invocation);
|
||||||
|
|
@ -217,7 +217,7 @@ public class AbstractClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSelect_Invokersize2AndselectNotNull() throws Exception {
|
void testSelect_Invokersize2AndselectNotNull() throws Exception {
|
||||||
invokers.clear();
|
invokers.clear();
|
||||||
invokers.add(invoker2);
|
invokers.add(invoker2);
|
||||||
invokers.add(invoker4);
|
invokers.add(invoker4);
|
||||||
|
|
@ -238,14 +238,14 @@ public class AbstractClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSelect_multiInvokers() throws Exception {
|
void testSelect_multiInvokers() throws Exception {
|
||||||
testSelect_multiInvokers(RoundRobinLoadBalance.NAME);
|
testSelect_multiInvokers(RoundRobinLoadBalance.NAME);
|
||||||
testSelect_multiInvokers(LeastActiveLoadBalance.NAME);
|
testSelect_multiInvokers(LeastActiveLoadBalance.NAME);
|
||||||
testSelect_multiInvokers(RandomLoadBalance.NAME);
|
testSelect_multiInvokers(RandomLoadBalance.NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCloseAvailablecheck() {
|
void testCloseAvailablecheck() {
|
||||||
LoadBalance lb = mock(LoadBalance.class);
|
LoadBalance lb = mock(LoadBalance.class);
|
||||||
Map<String, String> queryMap = (Map<String, String> )url.getAttribute(REFER_KEY);
|
Map<String, String> queryMap = (Map<String, String> )url.getAttribute(REFER_KEY);
|
||||||
URL tmpUrl = turnRegistryUrlToConsumerUrl(url, queryMap);
|
URL tmpUrl = turnRegistryUrlToConsumerUrl(url, queryMap);
|
||||||
|
|
@ -273,7 +273,7 @@ public class AbstractClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDonotSelectAgainAndNoCheckAvailable() {
|
void testDonotSelectAgainAndNoCheckAvailable() {
|
||||||
|
|
||||||
LoadBalance lb = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(RoundRobinLoadBalance.NAME);
|
LoadBalance lb = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(RoundRobinLoadBalance.NAME);
|
||||||
initlistsize5();
|
initlistsize5();
|
||||||
|
|
@ -332,7 +332,7 @@ public class AbstractClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSelectAgainAndCheckAvailable() {
|
void testSelectAgainAndCheckAvailable() {
|
||||||
|
|
||||||
LoadBalance lb = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(RoundRobinLoadBalance.NAME);
|
LoadBalance lb = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(RoundRobinLoadBalance.NAME);
|
||||||
initlistsize5();
|
initlistsize5();
|
||||||
|
|
@ -457,7 +457,7 @@ public class AbstractClusterInvokerTest {
|
||||||
* Test balance.
|
* Test balance.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testSelectBalance() {
|
void testSelectBalance() {
|
||||||
|
|
||||||
LoadBalance lb = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(RoundRobinLoadBalance.NAME);
|
LoadBalance lb = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(RoundRobinLoadBalance.NAME);
|
||||||
initlistsize5();
|
initlistsize5();
|
||||||
|
|
@ -500,7 +500,7 @@ public class AbstractClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTimeoutExceptionCode() {
|
void testTimeoutExceptionCode() {
|
||||||
List<Invoker<DemoService>> invokers = new ArrayList<Invoker<DemoService>>();
|
List<Invoker<DemoService>> invokers = new ArrayList<Invoker<DemoService>>();
|
||||||
invokers.add(new Invoker<DemoService>() {
|
invokers.add(new Invoker<DemoService>() {
|
||||||
|
|
||||||
|
|
@ -529,22 +529,25 @@ public class AbstractClusterInvokerTest {
|
||||||
});
|
});
|
||||||
Directory<DemoService> directory = new StaticDirectory<DemoService>(invokers);
|
Directory<DemoService> directory = new StaticDirectory<DemoService>(invokers);
|
||||||
FailoverClusterInvoker<DemoService> failoverClusterInvoker = new FailoverClusterInvoker<DemoService>(directory);
|
FailoverClusterInvoker<DemoService> failoverClusterInvoker = new FailoverClusterInvoker<DemoService>(directory);
|
||||||
|
RpcInvocation invocation = new RpcInvocation("sayHello", DemoService.class.getName(), "", new Class<?>[0], new Object[0]);
|
||||||
try {
|
try {
|
||||||
failoverClusterInvoker.invoke(new RpcInvocation("sayHello", DemoService.class.getName(), "", new Class<?>[0], new Object[0]));
|
failoverClusterInvoker.invoke(invocation);
|
||||||
Assertions.fail();
|
Assertions.fail();
|
||||||
} catch (RpcException e) {
|
} catch (RpcException e) {
|
||||||
Assertions.assertEquals(RpcException.TIMEOUT_EXCEPTION, e.getCode());
|
Assertions.assertEquals(RpcException.TIMEOUT_EXCEPTION, e.getCode());
|
||||||
}
|
}
|
||||||
ForkingClusterInvoker<DemoService> forkingClusterInvoker = new ForkingClusterInvoker<DemoService>(directory);
|
ForkingClusterInvoker<DemoService> forkingClusterInvoker = new ForkingClusterInvoker<DemoService>(directory);
|
||||||
|
invocation = new RpcInvocation("sayHello", DemoService.class.getName(), "", new Class<?>[0], new Object[0]);
|
||||||
try {
|
try {
|
||||||
forkingClusterInvoker.invoke(new RpcInvocation("sayHello", DemoService.class.getName(), "", new Class<?>[0], new Object[0]));
|
forkingClusterInvoker.invoke(invocation);
|
||||||
Assertions.fail();
|
Assertions.fail();
|
||||||
} catch (RpcException e) {
|
} catch (RpcException e) {
|
||||||
Assertions.assertEquals(RpcException.TIMEOUT_EXCEPTION, e.getCode());
|
Assertions.assertEquals(RpcException.TIMEOUT_EXCEPTION, e.getCode());
|
||||||
}
|
}
|
||||||
FailfastClusterInvoker<DemoService> failfastClusterInvoker = new FailfastClusterInvoker<DemoService>(directory);
|
FailfastClusterInvoker<DemoService> failfastClusterInvoker = new FailfastClusterInvoker<DemoService>(directory);
|
||||||
|
invocation = new RpcInvocation("sayHello", DemoService.class.getName(), "", new Class<?>[0], new Object[0]);
|
||||||
try {
|
try {
|
||||||
failfastClusterInvoker.invoke(new RpcInvocation("sayHello", DemoService.class.getName(), "", new Class<?>[0], new Object[0]));
|
failfastClusterInvoker.invoke(invocation);
|
||||||
Assertions.fail();
|
Assertions.fail();
|
||||||
} catch (RpcException e) {
|
} catch (RpcException e) {
|
||||||
Assertions.assertEquals(RpcException.TIMEOUT_EXCEPTION, e.getCode());
|
Assertions.assertEquals(RpcException.TIMEOUT_EXCEPTION, e.getCode());
|
||||||
|
|
@ -555,7 +558,7 @@ public class AbstractClusterInvokerTest {
|
||||||
* Test mock invoker selector works as expected
|
* Test mock invoker selector works as expected
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMockedInvokerSelect() {
|
void testMockedInvokerSelect() {
|
||||||
initlistsize5();
|
initlistsize5();
|
||||||
invokers.add(mockedInvoker1);
|
invokers.add(mockedInvoker1);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ import static org.mockito.Mockito.mock;
|
||||||
/**
|
/**
|
||||||
* Test for AvailableClusterInvoker
|
* Test for AvailableClusterInvoker
|
||||||
*/
|
*/
|
||||||
public class AvailableClusterInvokerTest {
|
class AvailableClusterInvokerTest {
|
||||||
|
|
||||||
private final URL url = URL.valueOf("test://test:80/test");
|
private final URL url = URL.valueOf("test://test:80/test");
|
||||||
private final Invoker<AvailableClusterInvokerTest> invoker1 = mock(Invoker.class);
|
private final Invoker<AvailableClusterInvokerTest> invoker1 = mock(Invoker.class);
|
||||||
|
|
@ -87,7 +87,7 @@ public class AvailableClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvokeNoException() {
|
void testInvokeNoException() {
|
||||||
|
|
||||||
resetInvokerToNoException();
|
resetInvokerToNoException();
|
||||||
|
|
||||||
|
|
@ -97,7 +97,7 @@ public class AvailableClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvokeWithException() {
|
void testInvokeWithException() {
|
||||||
|
|
||||||
// remove invokers for test exception
|
// remove invokers for test exception
|
||||||
dic.list(invocation).removeAll(invokers);
|
dic.list(invocation).removeAll(invokers);
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ import static org.mockito.Mockito.mock;
|
||||||
/**
|
/**
|
||||||
* @see BroadcastClusterInvoker
|
* @see BroadcastClusterInvoker
|
||||||
*/
|
*/
|
||||||
public class BroadCastClusterInvokerTest {
|
class BroadCastClusterInvokerTest {
|
||||||
private URL url;
|
private URL url;
|
||||||
private Directory<DemoService> dic;
|
private Directory<DemoService> dic;
|
||||||
private RpcInvocation invocation;
|
private RpcInvocation invocation;
|
||||||
|
|
@ -74,7 +74,7 @@ public class BroadCastClusterInvokerTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNormal() {
|
void testNormal() {
|
||||||
given(dic.list(invocation)).willReturn(Arrays.asList(invoker1, invoker2, invoker3, invoker4));
|
given(dic.list(invocation)).willReturn(Arrays.asList(invoker1, invoker2, invoker3, invoker4));
|
||||||
// Every invoker will be called
|
// Every invoker will be called
|
||||||
clusterInvoker.invoke(invocation);
|
clusterInvoker.invoke(invocation);
|
||||||
|
|
@ -85,7 +85,7 @@ public class BroadCastClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEx() {
|
void testEx() {
|
||||||
given(dic.list(invocation)).willReturn(Arrays.asList(invoker1, invoker2, invoker3, invoker4));
|
given(dic.list(invocation)).willReturn(Arrays.asList(invoker1, invoker2, invoker3, invoker4));
|
||||||
invoker1.invokeThrowEx();
|
invoker1.invokeThrowEx();
|
||||||
assertThrows(RpcException.class, () -> {
|
assertThrows(RpcException.class, () -> {
|
||||||
|
|
@ -99,7 +99,7 @@ public class BroadCastClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailPercent() {
|
void testFailPercent() {
|
||||||
given(dic.list(invocation)).willReturn(Arrays.asList(invoker1, invoker2, invoker3, invoker4));
|
given(dic.list(invocation)).willReturn(Arrays.asList(invoker1, invoker2, invoker3, invoker4));
|
||||||
// We set the failure percentage to 75, which means that when the number of call failures is 4*(75/100) = 3,
|
// We set the failure percentage to 75, which means that when the number of call failures is 4*(75/100) = 3,
|
||||||
// an exception will be thrown directly and subsequent invokers will not be called.
|
// an exception will be thrown directly and subsequent invokers will not be called.
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.URL_MERGE_PROCES
|
||||||
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
|
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
|
||||||
|
|
||||||
|
|
||||||
public class ClusterUtilsTest {
|
class ClusterUtilsTest {
|
||||||
|
|
||||||
private ClusterUtils clusterUtils;
|
private ClusterUtils clusterUtils;
|
||||||
|
|
||||||
|
|
@ -55,7 +55,7 @@ public class ClusterUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMergeUrl() throws Exception {
|
void testMergeUrl() throws Exception {
|
||||||
URL providerURL = URL.valueOf("dubbo://localhost:55555");
|
URL providerURL = URL.valueOf("dubbo://localhost:55555");
|
||||||
providerURL = providerURL.setPath("path")
|
providerURL = providerURL.setPath("path")
|
||||||
.setUsername("username")
|
.setUsername("username")
|
||||||
|
|
@ -136,7 +136,7 @@ public class ClusterUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMergeLocalParams() {
|
void testMergeLocalParams() {
|
||||||
|
|
||||||
// Verify default ProviderURLMergeProcessor
|
// Verify default ProviderURLMergeProcessor
|
||||||
URL consumerURL = new URLBuilder(DUBBO_PROTOCOL, "localhost", 55555)
|
URL consumerURL = new URLBuilder(DUBBO_PROTOCOL, "localhost", 55555)
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ import java.util.concurrent.ThreadLocalRandom;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
public class ConnectivityValidationTest {
|
class ConnectivityValidationTest {
|
||||||
private Invoker invoker1;
|
private Invoker invoker1;
|
||||||
private Invoker invoker2;
|
private Invoker invoker2;
|
||||||
private Invoker invoker3;
|
private Invoker invoker3;
|
||||||
|
|
@ -134,7 +134,7 @@ public class ConnectivityValidationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBasic() throws InterruptedException {
|
void testBasic() throws InterruptedException {
|
||||||
Invocation invocation = new RpcInvocation();
|
Invocation invocation = new RpcInvocation();
|
||||||
LoadBalance loadBalance = new RandomLoadBalance();
|
LoadBalance loadBalance = new RandomLoadBalance();
|
||||||
|
|
||||||
|
|
@ -181,7 +181,7 @@ public class ConnectivityValidationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRetry() throws InterruptedException {
|
void testRetry() throws InterruptedException {
|
||||||
Invocation invocation = new RpcInvocation();
|
Invocation invocation = new RpcInvocation();
|
||||||
LoadBalance loadBalance = new RandomLoadBalance();
|
LoadBalance loadBalance = new RandomLoadBalance();
|
||||||
|
|
||||||
|
|
@ -204,7 +204,7 @@ public class ConnectivityValidationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRandomSelect() throws InterruptedException {
|
void testRandomSelect() throws InterruptedException {
|
||||||
Invocation invocation = new RpcInvocation();
|
Invocation invocation = new RpcInvocation();
|
||||||
LoadBalance loadBalance = new RandomLoadBalance();
|
LoadBalance loadBalance = new RandomLoadBalance();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ import static org.mockito.Mockito.mock;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public class FailSafeClusterInvokerTest {
|
class FailSafeClusterInvokerTest {
|
||||||
List<Invoker<DemoService>> invokers = new ArrayList<Invoker<DemoService>>();
|
List<Invoker<DemoService>> invokers = new ArrayList<Invoker<DemoService>>();
|
||||||
URL url = URL.valueOf("test://test:11/test");
|
URL url = URL.valueOf("test://test:11/test");
|
||||||
Invoker<DemoService> invoker = mock(Invoker.class);
|
Invoker<DemoService> invoker = mock(Invoker.class);
|
||||||
|
|
@ -82,7 +82,7 @@ public class FailSafeClusterInvokerTest {
|
||||||
|
|
||||||
//TODO assert error log
|
//TODO assert error log
|
||||||
@Test
|
@Test
|
||||||
public void testInvokeExceptoin() {
|
void testInvokeExceptoin() {
|
||||||
resetInvokerToException();
|
resetInvokerToException();
|
||||||
FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
|
FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
|
||||||
invoker.invoke(invocation);
|
invoker.invoke(invocation);
|
||||||
|
|
@ -90,7 +90,7 @@ public class FailSafeClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvokeNoExceptoin() {
|
void testInvokeNoExceptoin() {
|
||||||
|
|
||||||
resetInvokerToNoException();
|
resetInvokerToNoException();
|
||||||
|
|
||||||
|
|
@ -100,7 +100,7 @@ public class FailSafeClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoInvoke() {
|
void testNoInvoke() {
|
||||||
dic = mock(Directory.class);
|
dic = mock(Directory.class);
|
||||||
|
|
||||||
given(dic.getUrl()).willReturn(url);
|
given(dic.getUrl()).willReturn(url);
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ import static org.mockito.Mockito.mock;
|
||||||
* add annotation @TestMethodOrder, the testARetryFailed Method must to first execution
|
* add annotation @TestMethodOrder, the testARetryFailed Method must to first execution
|
||||||
*/
|
*/
|
||||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||||
public class FailbackClusterInvokerTest {
|
class FailbackClusterInvokerTest {
|
||||||
|
|
||||||
List<Invoker<FailbackClusterInvokerTest>> invokers = new ArrayList<>();
|
List<Invoker<FailbackClusterInvokerTest>> invokers = new ArrayList<>();
|
||||||
URL url = URL.valueOf("test://test:11/test?retries=2&failbacktasks=2");
|
URL url = URL.valueOf("test://test:11/test?retries=2&failbacktasks=2");
|
||||||
|
|
@ -104,7 +104,7 @@ public class FailbackClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvokeWithIllegalRetriesParam() {
|
void testInvokeWithIllegalRetriesParam() {
|
||||||
URL url = URL.valueOf("test://test:11/test?retries=-1&failbacktasks=2");
|
URL url = URL.valueOf("test://test:11/test?retries=-1&failbacktasks=2");
|
||||||
Directory<FailbackClusterInvokerTest> dic = mock(Directory.class);
|
Directory<FailbackClusterInvokerTest> dic = mock(Directory.class);
|
||||||
given(dic.getUrl()).willReturn(url);
|
given(dic.getUrl()).willReturn(url);
|
||||||
|
|
@ -117,7 +117,7 @@ public class FailbackClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvokeWithIllegalFailbacktasksParam() {
|
void testInvokeWithIllegalFailbacktasksParam() {
|
||||||
URL url = URL.valueOf("test://test:11/test?retries=2&failbacktasks=-1");
|
URL url = URL.valueOf("test://test:11/test?retries=2&failbacktasks=-1");
|
||||||
Directory<FailbackClusterInvokerTest> dic = mock(Directory.class);
|
Directory<FailbackClusterInvokerTest> dic = mock(Directory.class);
|
||||||
given(dic.getUrl()).willReturn(url);
|
given(dic.getUrl()).willReturn(url);
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ import static org.mockito.Mockito.mock;
|
||||||
* FailfastClusterInvokerTest
|
* FailfastClusterInvokerTest
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public class FailfastClusterInvokerTest {
|
class FailfastClusterInvokerTest {
|
||||||
List<Invoker<FailfastClusterInvokerTest>> invokers = new ArrayList<>();
|
List<Invoker<FailfastClusterInvokerTest>> invokers = new ArrayList<>();
|
||||||
URL url = URL.valueOf("test://test:11/test");
|
URL url = URL.valueOf("test://test:11/test");
|
||||||
Invoker<FailfastClusterInvokerTest> invoker1 = mock(Invoker.class);
|
Invoker<FailfastClusterInvokerTest> invoker1 = mock(Invoker.class);
|
||||||
|
|
@ -83,7 +83,7 @@ public class FailfastClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvokeException() {
|
void testInvokeException() {
|
||||||
Assertions.assertThrows(RpcException.class, () -> {
|
Assertions.assertThrows(RpcException.class, () -> {
|
||||||
resetInvoker1ToException();
|
resetInvoker1ToException();
|
||||||
FailfastClusterInvoker<FailfastClusterInvokerTest> invoker = new FailfastClusterInvoker<>(dic);
|
FailfastClusterInvoker<FailfastClusterInvokerTest> invoker = new FailfastClusterInvoker<>(dic);
|
||||||
|
|
@ -93,7 +93,7 @@ public class FailfastClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvokeBizException() {
|
void testInvokeBizException() {
|
||||||
given(invoker1.invoke(invocation)).willThrow(new RpcException(RpcException.BIZ_EXCEPTION));
|
given(invoker1.invoke(invocation)).willThrow(new RpcException(RpcException.BIZ_EXCEPTION));
|
||||||
given(invoker1.getUrl()).willReturn(url);
|
given(invoker1.getUrl()).willReturn(url);
|
||||||
given(invoker1.getInterface()).willReturn(FailfastClusterInvokerTest.class);
|
given(invoker1.getInterface()).willReturn(FailfastClusterInvokerTest.class);
|
||||||
|
|
@ -109,7 +109,7 @@ public class FailfastClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvokeNoException() {
|
void testInvokeNoException() {
|
||||||
|
|
||||||
resetInvoker1ToNoException();
|
resetInvoker1ToNoException();
|
||||||
|
|
||||||
|
|
@ -119,7 +119,7 @@ public class FailfastClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoInvoke() {
|
void testNoInvoke() {
|
||||||
dic = mock(Directory.class);
|
dic = mock(Directory.class);
|
||||||
|
|
||||||
given(dic.getUrl()).willReturn(url);
|
given(dic.getUrl()).willReturn(url);
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ import static org.mockito.Mockito.mock;
|
||||||
* FailoverClusterInvokerTest
|
* FailoverClusterInvokerTest
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public class FailoverClusterInvokerTest {
|
class FailoverClusterInvokerTest {
|
||||||
private final int retries = 5;
|
private final int retries = 5;
|
||||||
private final URL url = URL.valueOf("test://test:11/test?retries=" + retries);
|
private final URL url = URL.valueOf("test://test:11/test?retries=" + retries);
|
||||||
private final Invoker<FailoverClusterInvokerTest> invoker1 = mock(Invoker.class);
|
private final Invoker<FailoverClusterInvokerTest> invoker1 = mock(Invoker.class);
|
||||||
|
|
@ -80,7 +80,7 @@ public class FailoverClusterInvokerTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvokeWithRuntimeException() {
|
void testInvokeWithRuntimeException() {
|
||||||
given(invoker1.invoke(invocation)).willThrow(new RuntimeException());
|
given(invoker1.invoke(invocation)).willThrow(new RuntimeException());
|
||||||
given(invoker1.isAvailable()).willReturn(true);
|
given(invoker1.isAvailable()).willReturn(true);
|
||||||
given(invoker1.getUrl()).willReturn(url);
|
given(invoker1.getUrl()).willReturn(url);
|
||||||
|
|
@ -102,7 +102,7 @@ public class FailoverClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvokeWithRPCException() {
|
void testInvokeWithRPCException() {
|
||||||
given(invoker1.invoke(invocation)).willThrow(new RpcException());
|
given(invoker1.invoke(invocation)).willThrow(new RpcException());
|
||||||
given(invoker1.isAvailable()).willReturn(true);
|
given(invoker1.isAvailable()).willReturn(true);
|
||||||
given(invoker1.getUrl()).willReturn(url);
|
given(invoker1.getUrl()).willReturn(url);
|
||||||
|
|
@ -121,7 +121,7 @@ public class FailoverClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvoke_retryTimes() {
|
void testInvoke_retryTimes() {
|
||||||
given(invoker1.invoke(invocation)).willThrow(new RpcException(RpcException.TIMEOUT_EXCEPTION));
|
given(invoker1.invoke(invocation)).willThrow(new RpcException(RpcException.TIMEOUT_EXCEPTION));
|
||||||
given(invoker1.isAvailable()).willReturn(false);
|
given(invoker1.isAvailable()).willReturn(false);
|
||||||
given(invoker1.getUrl()).willReturn(url);
|
given(invoker1.getUrl()).willReturn(url);
|
||||||
|
|
@ -144,7 +144,7 @@ public class FailoverClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvoke_retryTimes2() {
|
void testInvoke_retryTimes2() {
|
||||||
int finalRetries = 1;
|
int finalRetries = 1;
|
||||||
given(invoker1.invoke(invocation)).willThrow(new RpcException(RpcException.TIMEOUT_EXCEPTION));
|
given(invoker1.invoke(invocation)).willThrow(new RpcException(RpcException.TIMEOUT_EXCEPTION));
|
||||||
given(invoker1.isAvailable()).willReturn(false);
|
given(invoker1.isAvailable()).willReturn(false);
|
||||||
|
|
@ -171,7 +171,7 @@ public class FailoverClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvoke_retryTimes_withBizException() {
|
void testInvoke_retryTimes_withBizException() {
|
||||||
given(invoker1.invoke(invocation)).willThrow(new RpcException(RpcException.BIZ_EXCEPTION));
|
given(invoker1.invoke(invocation)).willThrow(new RpcException(RpcException.BIZ_EXCEPTION));
|
||||||
given(invoker1.isAvailable()).willReturn(false);
|
given(invoker1.isAvailable()).willReturn(false);
|
||||||
given(invoker1.getUrl()).willReturn(url);
|
given(invoker1.getUrl()).willReturn(url);
|
||||||
|
|
@ -193,7 +193,7 @@ public class FailoverClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvoke_without_retry() {
|
void testInvoke_without_retry() {
|
||||||
int withoutRetry = 0;
|
int withoutRetry = 0;
|
||||||
final URL url = URL.valueOf("test://localhost/" + Demo.class.getName() + "?loadbalance=roundrobin&retries=" + withoutRetry);
|
final URL url = URL.valueOf("test://localhost/" + Demo.class.getName() + "?loadbalance=roundrobin&retries=" + withoutRetry);
|
||||||
RpcException exception = new RpcException(RpcException.TIMEOUT_EXCEPTION);
|
RpcException exception = new RpcException(RpcException.TIMEOUT_EXCEPTION);
|
||||||
|
|
@ -220,7 +220,7 @@ public class FailoverClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvoke_when_retry_illegal() {
|
void testInvoke_when_retry_illegal() {
|
||||||
int illegalRetry = -1;
|
int illegalRetry = -1;
|
||||||
final URL url = URL.valueOf("test://localhost/" + Demo.class.getName() + "?loadbalance=roundrobin&retries=" + illegalRetry);
|
final URL url = URL.valueOf("test://localhost/" + Demo.class.getName() + "?loadbalance=roundrobin&retries=" + illegalRetry);
|
||||||
RpcException exception = new RpcException(RpcException.TIMEOUT_EXCEPTION);
|
RpcException exception = new RpcException(RpcException.TIMEOUT_EXCEPTION);
|
||||||
|
|
@ -247,7 +247,7 @@ public class FailoverClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoInvoke() {
|
void testNoInvoke() {
|
||||||
dic = mock(Directory.class);
|
dic = mock(Directory.class);
|
||||||
|
|
||||||
given(dic.getUrl()).willReturn(url);
|
given(dic.getUrl()).willReturn(url);
|
||||||
|
|
@ -273,7 +273,7 @@ public class FailoverClusterInvokerTest {
|
||||||
* then we should reselect from the latest invokers before retry.
|
* then we should reselect from the latest invokers before retry.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testInvokerDestroyAndReList() {
|
void testInvokerDestroyAndReList() {
|
||||||
final URL url = URL.valueOf("test://localhost/" + Demo.class.getName() + "?loadbalance=roundrobin&retries=" + retries);
|
final URL url = URL.valueOf("test://localhost/" + Demo.class.getName() + "?loadbalance=roundrobin&retries=" + retries);
|
||||||
RpcException exception = new RpcException(RpcException.TIMEOUT_EXCEPTION);
|
RpcException exception = new RpcException(RpcException.TIMEOUT_EXCEPTION);
|
||||||
MockInvoker<Demo> invoker1 = new MockInvoker<>(Demo.class, url);
|
MockInvoker<Demo> invoker1 = new MockInvoker<>(Demo.class, url);
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ import static org.mockito.Mockito.mock;
|
||||||
* ForkingClusterInvokerTest
|
* ForkingClusterInvokerTest
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public class ForkingClusterInvokerTest {
|
class ForkingClusterInvokerTest {
|
||||||
|
|
||||||
private List<Invoker<ForkingClusterInvokerTest>> invokers = new ArrayList<>();
|
private List<Invoker<ForkingClusterInvokerTest>> invokers = new ArrayList<>();
|
||||||
private URL url = URL.valueOf("test://test:11/test?forks=2");
|
private URL url = URL.valueOf("test://test:11/test?forks=2");
|
||||||
|
|
@ -105,7 +105,7 @@ public class ForkingClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvokeException() {
|
void testInvokeException() {
|
||||||
resetInvokerToException();
|
resetInvokerToException();
|
||||||
ForkingClusterInvoker<ForkingClusterInvokerTest> invoker = new ForkingClusterInvoker<>(dic);
|
ForkingClusterInvoker<ForkingClusterInvokerTest> invoker = new ForkingClusterInvoker<>(dic);
|
||||||
|
|
||||||
|
|
@ -119,7 +119,7 @@ public class ForkingClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testClearRpcContext() {
|
void testClearRpcContext() {
|
||||||
resetInvokerToException();
|
resetInvokerToException();
|
||||||
ForkingClusterInvoker<ForkingClusterInvokerTest> invoker = new ForkingClusterInvoker<>(dic);
|
ForkingClusterInvoker<ForkingClusterInvokerTest> invoker = new ForkingClusterInvoker<>(dic);
|
||||||
|
|
||||||
|
|
@ -142,7 +142,7 @@ public class ForkingClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvokeNoException() {
|
void testInvokeNoException() {
|
||||||
|
|
||||||
resetInvokerToNoException();
|
resetInvokerToNoException();
|
||||||
|
|
||||||
|
|
@ -152,7 +152,7 @@ public class ForkingClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvokeWithIllegalForksParam() {
|
void testInvokeWithIllegalForksParam() {
|
||||||
URL url = URL.valueOf("test://test:11/test?forks=-1");
|
URL url = URL.valueOf("test://test:11/test?forks=-1");
|
||||||
given(dic.getUrl()).willReturn(url);
|
given(dic.getUrl()).willReturn(url);
|
||||||
given(dic.getConsumerUrl()).willReturn(url);
|
given(dic.getConsumerUrl()).willReturn(url);
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class Menu {
|
class Menu {
|
||||||
|
|
||||||
private Map<String, List<String>> menus = new HashMap<String, List<String>>();
|
private Map<String, List<String>> menus = new HashMap<String, List<String>>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ import static org.junit.jupiter.api.Assertions.fail;
|
||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
public class MergeableClusterInvokerTest {
|
class MergeableClusterInvokerTest {
|
||||||
|
|
||||||
private Directory directory = mock(Directory.class);
|
private Directory directory = mock(Directory.class);
|
||||||
private Invoker firstInvoker = mock(Invoker.class);
|
private Invoker firstInvoker = mock(Invoker.class);
|
||||||
|
|
@ -102,7 +102,7 @@ public class MergeableClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetMenuSuccessfully() {
|
void testGetMenuSuccessfully() {
|
||||||
|
|
||||||
// setup
|
// setup
|
||||||
url = url.addParameter(MERGER_KEY, ".merge");
|
url = url.addParameter(MERGER_KEY, ".merge");
|
||||||
|
|
@ -173,7 +173,7 @@ public class MergeableClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddMenu() {
|
void testAddMenu() {
|
||||||
|
|
||||||
String menu = "first";
|
String menu = "first";
|
||||||
List<String> menuItems = new ArrayList<String>() {
|
List<String> menuItems = new ArrayList<String>() {
|
||||||
|
|
@ -219,7 +219,7 @@ public class MergeableClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddMenu1() {
|
void testAddMenu1() {
|
||||||
|
|
||||||
// setup
|
// setup
|
||||||
url = url.addParameter(MERGER_KEY, ".merge");
|
url = url.addParameter(MERGER_KEY, ".merge");
|
||||||
|
|
@ -284,7 +284,7 @@ public class MergeableClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvokerToNoInvokerAvailableException() {
|
void testInvokerToNoInvokerAvailableException() {
|
||||||
String menu = "first";
|
String menu = "first";
|
||||||
List<String> menuItems = new ArrayList<String>() {
|
List<String> menuItems = new ArrayList<String>() {
|
||||||
{
|
{
|
||||||
|
|
@ -339,7 +339,7 @@ public class MergeableClusterInvokerTest {
|
||||||
* test when network exception
|
* test when network exception
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testInvokerToException() {
|
void testInvokerToException() {
|
||||||
String menu = "first";
|
String menu = "first";
|
||||||
List<String> menuItems = new ArrayList<String>() {
|
List<String> menuItems = new ArrayList<String>() {
|
||||||
{
|
{
|
||||||
|
|
@ -391,7 +391,7 @@ public class MergeableClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetMenuResultHasException() {
|
void testGetMenuResultHasException() {
|
||||||
|
|
||||||
// setup
|
// setup
|
||||||
url = url.addParameter(MERGER_KEY, ".merge");
|
url = url.addParameter(MERGER_KEY, ".merge");
|
||||||
|
|
@ -437,7 +437,7 @@ public class MergeableClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetMenuWithMergerDefault() {
|
void testGetMenuWithMergerDefault() {
|
||||||
|
|
||||||
// setup
|
// setup
|
||||||
url = url.addParameter(MERGER_KEY, "default");
|
url = url.addParameter(MERGER_KEY, "default");
|
||||||
|
|
@ -501,7 +501,7 @@ public class MergeableClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDestroy() {
|
void testDestroy() {
|
||||||
given(invocation.getMethodName()).willReturn("getMenu");
|
given(invocation.getMethodName()).willReturn("getMenu");
|
||||||
given(invocation.getParameterTypes()).willReturn(new Class<?>[]{});
|
given(invocation.getParameterTypes()).willReturn(new Class<?>[]{});
|
||||||
given(invocation.getArguments()).willReturn(new Object[]{});
|
given(invocation.getArguments()).willReturn(new Object[]{});
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
|
||||||
import static org.apache.dubbo.common.constants.CommonConstants.TIMESTAMP_KEY;
|
import static org.apache.dubbo.common.constants.CommonConstants.TIMESTAMP_KEY;
|
||||||
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
|
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
|
||||||
|
|
||||||
public class DefaultProviderURLMergeProcessorTest {
|
class DefaultProviderURLMergeProcessorTest {
|
||||||
|
|
||||||
private ProviderURLMergeProcessor providerURLMergeProcessor;
|
private ProviderURLMergeProcessor providerURLMergeProcessor;
|
||||||
|
|
||||||
|
|
@ -57,7 +57,7 @@ public class DefaultProviderURLMergeProcessorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMergeUrl() throws Exception {
|
void testMergeUrl() throws Exception {
|
||||||
URL providerURL = URL.valueOf("dubbo://localhost:55555");
|
URL providerURL = URL.valueOf("dubbo://localhost:55555");
|
||||||
providerURL = providerURL.setPath("path")
|
providerURL = providerURL.setPath("path")
|
||||||
.setUsername("username")
|
.setUsername("username")
|
||||||
|
|
@ -124,7 +124,7 @@ public class DefaultProviderURLMergeProcessorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUseProviderParams() {
|
void testUseProviderParams() {
|
||||||
// present in both local and remote, but uses remote value.
|
// present in both local and remote, but uses remote value.
|
||||||
URL localURL = URL.valueOf("dubbo://localhost:20880/DemoService?version=local&group=local&dubbo=local&release=local" +
|
URL localURL = URL.valueOf("dubbo://localhost:20880/DemoService?version=local&group=local&dubbo=local&release=local" +
|
||||||
"&methods=local&tag=local×tamp=local");
|
"&methods=local&tag=local×tamp=local");
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ import static org.apache.dubbo.common.constants.RegistryConstants.ZONE_KEY;
|
||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
public class ZoneAwareClusterInvokerTest {
|
class ZoneAwareClusterInvokerTest {
|
||||||
|
|
||||||
private Directory directory = mock(Directory.class);
|
private Directory directory = mock(Directory.class);
|
||||||
private ClusterInvoker firstInvoker = mock(ClusterInvoker.class);
|
private ClusterInvoker firstInvoker = mock(ClusterInvoker.class);
|
||||||
|
|
@ -54,7 +54,7 @@ public class ZoneAwareClusterInvokerTest {
|
||||||
String unexpectedValue = "unexpected";
|
String unexpectedValue = "unexpected";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPreferredStrategy() {
|
void testPreferredStrategy() {
|
||||||
given(invocation.getParameterTypes()).willReturn(new Class<?>[]{});
|
given(invocation.getParameterTypes()).willReturn(new Class<?>[]{});
|
||||||
given(invocation.getArguments()).willReturn(new Object[]{});
|
given(invocation.getArguments()).willReturn(new Object[]{});
|
||||||
given(invocation.getObjectAttachments()).willReturn(new HashMap<>());
|
given(invocation.getObjectAttachments()).willReturn(new HashMap<>());
|
||||||
|
|
@ -95,7 +95,7 @@ public class ZoneAwareClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRegistryZoneStrategy() {
|
void testRegistryZoneStrategy() {
|
||||||
String zoneKey = "zone";
|
String zoneKey = "zone";
|
||||||
|
|
||||||
given(invocation.getParameterTypes()).willReturn(new Class<?>[]{});
|
given(invocation.getParameterTypes()).willReturn(new Class<?>[]{});
|
||||||
|
|
@ -139,7 +139,7 @@ public class ZoneAwareClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRegistryZoneForceStrategy() {
|
void testRegistryZoneForceStrategy() {
|
||||||
String zoneKey = "zone";
|
String zoneKey = "zone";
|
||||||
|
|
||||||
given(invocation.getParameterTypes()).willReturn(new Class<?>[]{});
|
given(invocation.getParameterTypes()).willReturn(new Class<?>[]{});
|
||||||
|
|
|
||||||
|
|
@ -42,10 +42,10 @@ import static org.apache.dubbo.common.constants.CommonConstants.REFERENCE_FILTER
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
public class AbstractClusterTest {
|
class AbstractClusterTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuildClusterInvokerChain() {
|
void testBuildClusterInvokerChain() {
|
||||||
|
|
||||||
Map<String, String> parameters = new HashMap<>();
|
Map<String, String> parameters = new HashMap<>();
|
||||||
parameters.put(INTERFACE_KEY, DemoService.class.getName());
|
parameters.put(INTERFACE_KEY, DemoService.class.getName());
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ import java.util.concurrent.ExecutionException;
|
||||||
import static org.apache.dubbo.common.constants.CommonConstants.PATH_KEY;
|
import static org.apache.dubbo.common.constants.CommonConstants.PATH_KEY;
|
||||||
import static org.apache.dubbo.rpc.cluster.Constants.REFER_KEY;
|
import static org.apache.dubbo.rpc.cluster.Constants.REFER_KEY;
|
||||||
|
|
||||||
public class MockClusterInvokerTest {
|
class MockClusterInvokerTest {
|
||||||
|
|
||||||
List<Invoker<IHelloService>> invokers = new ArrayList<Invoker<IHelloService>>();
|
List<Invoker<IHelloService>> invokers = new ArrayList<Invoker<IHelloService>>();
|
||||||
|
|
||||||
|
|
@ -56,7 +56,7 @@ public class MockClusterInvokerTest {
|
||||||
* Test if mock policy works fine: fail-mock
|
* Test if mock policy works fine: fail-mock
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerInvoke_normal() {
|
void testMockInvokerInvoke_normal() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName());
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName());
|
||||||
url = url.addParameter(REFER_KEY,
|
url = url.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
||||||
|
|
@ -86,7 +86,7 @@ public class MockClusterInvokerTest {
|
||||||
* Test if mock policy works fine: fail-mock
|
* Test if mock policy works fine: fail-mock
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerInvoke_failmock() {
|
void testMockInvokerInvoke_failmock() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
||||||
|
|
@ -126,7 +126,7 @@ public class MockClusterInvokerTest {
|
||||||
* Test if mock policy works fine: force-mock
|
* Test if mock policy works fine: force-mock
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerInvoke_forcemock() {
|
void testMockInvokerInvoke_forcemock() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
||||||
|
|
@ -165,7 +165,7 @@ public class MockClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerInvoke_forcemock_defaultreturn() {
|
void testMockInvokerInvoke_forcemock_defaultreturn() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
||||||
|
|
@ -190,7 +190,7 @@ public class MockClusterInvokerTest {
|
||||||
* Test if mock policy works fine: fail-mock
|
* Test if mock policy works fine: fail-mock
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerFromOverride_Invoke_Fock_someMethods() {
|
void testMockInvokerFromOverride_Invoke_Fock_someMethods() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
||||||
|
|
@ -226,7 +226,7 @@ public class MockClusterInvokerTest {
|
||||||
* Test if mock policy works fine: fail-mock
|
* Test if mock policy works fine: fail-mock
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerFromOverride_Invoke_Fock_WithOutDefault() {
|
void testMockInvokerFromOverride_Invoke_Fock_WithOutDefault() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
||||||
|
|
@ -261,7 +261,7 @@ public class MockClusterInvokerTest {
|
||||||
* Test if mock policy works fine: fail-mock
|
* Test if mock policy works fine: fail-mock
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerFromOverride_Invoke_Fock_WithDefault() {
|
void testMockInvokerFromOverride_Invoke_Fock_WithDefault() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
||||||
|
|
@ -299,7 +299,7 @@ public class MockClusterInvokerTest {
|
||||||
* Test if mock policy works fine: fail-mock
|
* Test if mock policy works fine: fail-mock
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerFromOverride_Invoke_Fock_WithFailDefault() {
|
void testMockInvokerFromOverride_Invoke_Fock_WithFailDefault() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
||||||
|
|
@ -337,7 +337,7 @@ public class MockClusterInvokerTest {
|
||||||
* Test if mock policy works fine: fail-mock
|
* Test if mock policy works fine: fail-mock
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerFromOverride_Invoke_Fock_WithForceDefault() {
|
void testMockInvokerFromOverride_Invoke_Fock_WithForceDefault() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
||||||
|
|
@ -375,7 +375,7 @@ public class MockClusterInvokerTest {
|
||||||
* Test if mock policy works fine: fail-mock
|
* Test if mock policy works fine: fail-mock
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerFromOverride_Invoke_Fock_Default() {
|
void testMockInvokerFromOverride_Invoke_Fock_Default() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
||||||
|
|
@ -405,7 +405,7 @@ public class MockClusterInvokerTest {
|
||||||
* Test if mock policy works fine: fail-mock
|
* Test if mock policy works fine: fail-mock
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerFromOverride_Invoke_checkCompatible_return() {
|
void testMockInvokerFromOverride_Invoke_checkCompatible_return() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
||||||
|
|
@ -433,7 +433,7 @@ public class MockClusterInvokerTest {
|
||||||
* Test if mock policy works fine: fail-mock
|
* Test if mock policy works fine: fail-mock
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerFromOverride_Invoke_checkCompatible_ImplMock() {
|
void testMockInvokerFromOverride_Invoke_checkCompatible_ImplMock() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
||||||
|
|
@ -452,7 +452,7 @@ public class MockClusterInvokerTest {
|
||||||
* Test if mock policy works fine: fail-mock
|
* Test if mock policy works fine: fail-mock
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerFromOverride_Invoke_checkCompatible_ImplMock2() {
|
void testMockInvokerFromOverride_Invoke_checkCompatible_ImplMock2() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName() + "&" + "mock=fail"))
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName() + "&" + "mock=fail"))
|
||||||
|
|
@ -469,7 +469,7 @@ public class MockClusterInvokerTest {
|
||||||
* Test if mock policy works fine: fail-mock
|
* Test if mock policy works fine: fail-mock
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerFromOverride_Invoke_checkCompatible_ImplMock3() {
|
void testMockInvokerFromOverride_Invoke_checkCompatible_ImplMock3() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName() + "&" + "mock=force"));
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName() + "&" + "mock=force"));
|
||||||
|
|
@ -482,7 +482,7 @@ public class MockClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerFromOverride_Invoke_check_String() {
|
void testMockInvokerFromOverride_Invoke_check_String() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter("getSomething.mock", "force:return 1688")
|
.addParameter("getSomething.mock", "force:return 1688")
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
|
|
@ -499,7 +499,7 @@ public class MockClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerFromOverride_Invoke_check_int() {
|
void testMockInvokerFromOverride_Invoke_check_int() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
||||||
|
|
@ -515,7 +515,7 @@ public class MockClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerFromOverride_Invoke_check_boolean() {
|
void testMockInvokerFromOverride_Invoke_check_boolean() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
||||||
|
|
@ -531,7 +531,7 @@ public class MockClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerFromOverride_Invoke_check_Boolean() {
|
void testMockInvokerFromOverride_Invoke_check_Boolean() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
||||||
|
|
@ -547,7 +547,7 @@ public class MockClusterInvokerTest {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerFromOverride_Invoke_check_ListString_empty() {
|
void testMockInvokerFromOverride_Invoke_check_ListString_empty() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
||||||
|
|
@ -563,7 +563,7 @@ public class MockClusterInvokerTest {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerFromOverride_Invoke_check_ListString() {
|
void testMockInvokerFromOverride_Invoke_check_ListString() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
||||||
|
|
@ -581,7 +581,7 @@ public class MockClusterInvokerTest {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerFromOverride_Invoke_check_ListPojo_empty() {
|
void testMockInvokerFromOverride_Invoke_check_ListPojo_empty() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
||||||
|
|
@ -595,7 +595,7 @@ public class MockClusterInvokerTest {
|
||||||
Assertions.assertEquals(0, ((List<User>) ret.getValue()).size());
|
Assertions.assertEquals(0, ((List<User>) ret.getValue()).size());
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerFromOverride_Invoke_check_ListPojoAsync() throws ExecutionException, InterruptedException {
|
void testMockInvokerFromOverride_Invoke_check_ListPojoAsync() throws ExecutionException, InterruptedException {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
||||||
|
|
@ -620,7 +620,7 @@ public class MockClusterInvokerTest {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerFromOverride_Invoke_check_ListPojo() {
|
void testMockInvokerFromOverride_Invoke_check_ListPojo() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
||||||
|
|
@ -638,7 +638,7 @@ public class MockClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerFromOverride_Invoke_check_ListPojo_error() {
|
void testMockInvokerFromOverride_Invoke_check_ListPojo_error() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
||||||
|
|
@ -655,7 +655,7 @@ public class MockClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerFromOverride_Invoke_force_throw() {
|
void testMockInvokerFromOverride_Invoke_force_throw() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
||||||
|
|
@ -674,7 +674,7 @@ public class MockClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerFromOverride_Invoke_force_throwCustemException() throws Throwable {
|
void testMockInvokerFromOverride_Invoke_force_throwCustemException() throws Throwable {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
||||||
|
|
@ -693,7 +693,7 @@ public class MockClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerFromOverride_Invoke_force_throwCustemExceptionNotFound() {
|
void testMockInvokerFromOverride_Invoke_force_throwCustemExceptionNotFound() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
||||||
|
|
@ -712,7 +712,7 @@ public class MockClusterInvokerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerFromOverride_Invoke_mock_false() {
|
void testMockInvokerFromOverride_Invoke_mock_false() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloService.class.getName())
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
URL.encode(PATH_KEY + "=" + IHelloService.class.getName()
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.PATH_KEY;
|
||||||
import static org.apache.dubbo.rpc.Constants.MOCK_KEY;
|
import static org.apache.dubbo.rpc.Constants.MOCK_KEY;
|
||||||
import static org.apache.dubbo.rpc.cluster.Constants.REFER_KEY;
|
import static org.apache.dubbo.rpc.cluster.Constants.REFER_KEY;
|
||||||
|
|
||||||
public class MockProviderRpcExceptionTest {
|
class MockProviderRpcExceptionTest {
|
||||||
|
|
||||||
List<Invoker<IHelloRpcService>> invokers = new ArrayList<Invoker<IHelloRpcService>>();
|
List<Invoker<IHelloRpcService>> invokers = new ArrayList<Invoker<IHelloRpcService>>();
|
||||||
|
|
||||||
|
|
@ -53,7 +53,7 @@ public class MockProviderRpcExceptionTest {
|
||||||
* Test if mock policy works fine: ProviderRpcException
|
* Test if mock policy works fine: ProviderRpcException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMockInvokerProviderRpcException() {
|
void testMockInvokerProviderRpcException() {
|
||||||
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloRpcService.class.getName());
|
URL url = URL.valueOf("remote://1.2.3.4/" + IHelloRpcService.class.getName());
|
||||||
url = url.addParameter(MOCK_KEY, "true").addParameter("invoke_return_error", "true")
|
url = url.addParameter(MOCK_KEY, "true").addParameter("invoke_return_error", "true")
|
||||||
.addParameter(REFER_KEY,
|
.addParameter(REFER_KEY,
|
||||||
|
|
|
||||||
|
|
@ -349,8 +349,12 @@ class URL implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public URL setProtocol(String protocol) {
|
public URL setProtocol(String protocol) {
|
||||||
URLAddress newURLAddress = urlAddress.setProtocol(protocol);
|
if (urlAddress == null) {
|
||||||
return returnURL(newURLAddress);
|
return new ServiceConfigURL(protocol, getHost(), getPort(), getPath(), getParameters());
|
||||||
|
} else {
|
||||||
|
URLAddress newURLAddress = urlAddress.setProtocol(protocol);
|
||||||
|
return returnURL(newURLAddress);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
|
|
@ -358,8 +362,12 @@ class URL implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public URL setUsername(String username) {
|
public URL setUsername(String username) {
|
||||||
URLAddress newURLAddress = urlAddress.setUsername(username);
|
if (urlAddress == null) {
|
||||||
return returnURL(newURLAddress);
|
return new ServiceConfigURL(getProtocol(), getHost(), getPort(), getPath(), getParameters()).setUsername(username);
|
||||||
|
} else {
|
||||||
|
URLAddress newURLAddress = urlAddress.setUsername(username);
|
||||||
|
return returnURL(newURLAddress);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPassword() {
|
public String getPassword() {
|
||||||
|
|
@ -367,8 +375,12 @@ class URL implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public URL setPassword(String password) {
|
public URL setPassword(String password) {
|
||||||
URLAddress newURLAddress = urlAddress.setPassword(password);
|
if (urlAddress == null) {
|
||||||
return returnURL(newURLAddress);
|
return new ServiceConfigURL(getProtocol(), getHost(), getPort(), getPath(), getParameters()).setPassword(password);
|
||||||
|
} else {
|
||||||
|
URLAddress newURLAddress = urlAddress.setPassword(password);
|
||||||
|
return returnURL(newURLAddress);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -425,8 +437,12 @@ class URL implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public URL setHost(String host) {
|
public URL setHost(String host) {
|
||||||
URLAddress newURLAddress = urlAddress.setHost(host);
|
if (urlAddress == null) {
|
||||||
return returnURL(newURLAddress);
|
return new ServiceConfigURL(getProtocol(), host, getPort(), getPath(), getParameters());
|
||||||
|
} else {
|
||||||
|
URLAddress newURLAddress = urlAddress.setHost(host);
|
||||||
|
return returnURL(newURLAddress);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -435,8 +451,12 @@ class URL implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public URL setPort(int port) {
|
public URL setPort(int port) {
|
||||||
URLAddress newURLAddress = urlAddress.setPort(port);
|
if (urlAddress == null) {
|
||||||
return returnURL(newURLAddress);
|
return new ServiceConfigURL(getProtocol(), getHost(), port, getPath(), getParameters());
|
||||||
|
} else {
|
||||||
|
URLAddress newURLAddress = urlAddress.setPort(port);
|
||||||
|
return returnURL(newURLAddress);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPort(int defaultPort) {
|
public int getPort(int defaultPort) {
|
||||||
|
|
@ -445,7 +465,7 @@ class URL implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAddress() {
|
public String getAddress() {
|
||||||
return urlAddress.getAddress();
|
return urlAddress == null ? null : urlAddress.getAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
public URL setAddress(String address) {
|
public URL setAddress(String address) {
|
||||||
|
|
@ -458,12 +478,16 @@ class URL implements Serializable {
|
||||||
} else {
|
} else {
|
||||||
host = address;
|
host = address;
|
||||||
}
|
}
|
||||||
URLAddress newURLAddress = urlAddress.setAddress(host, port);
|
if (urlAddress == null) {
|
||||||
return returnURL(newURLAddress);
|
return new ServiceConfigURL(getProtocol(), host, port, getPath(), getParameters());
|
||||||
|
} else {
|
||||||
|
URLAddress newURLAddress = urlAddress.setAddress(host, port);
|
||||||
|
return returnURL(newURLAddress);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIp() {
|
public String getIp() {
|
||||||
return urlAddress.getIp();
|
return urlAddress == null ? null : urlAddress.getIp();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBackupAddress() {
|
public String getBackupAddress() {
|
||||||
|
|
@ -499,8 +523,12 @@ class URL implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public URL setPath(String path) {
|
public URL setPath(String path) {
|
||||||
URLAddress newURLAddress = urlAddress.setPath(path);
|
if (urlAddress == null) {
|
||||||
return returnURL(newURLAddress);
|
return new ServiceConfigURL(getProtocol(), getHost(), getPort(), path, getParameters());
|
||||||
|
} else {
|
||||||
|
URLAddress newURLAddress = urlAddress.setPath(path);
|
||||||
|
return returnURL(newURLAddress);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAbsolutePath() {
|
public String getAbsolutePath() {
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,10 @@ import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_VERSION;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
public class BaseServiceMetadataTest {
|
class BaseServiceMetadataTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
void test() {
|
||||||
BaseServiceMetadata baseServiceMetadata = new BaseServiceMetadata();
|
BaseServiceMetadata baseServiceMetadata = new BaseServiceMetadata();
|
||||||
baseServiceMetadata.setGroup("group1");
|
baseServiceMetadata.setGroup("group1");
|
||||||
baseServiceMetadata.setServiceInterfaceName("org.apache.dubbo.common.TestInterface");
|
baseServiceMetadata.setServiceInterfaceName("org.apache.dubbo.common.TestInterface");
|
||||||
|
|
@ -63,4 +63,4 @@ public class BaseServiceMetadataTest {
|
||||||
assertEquals(BaseServiceMetadata.revertDisplayServiceKey(null).getDisplayServiceKey(),"null:null");
|
assertEquals(BaseServiceMetadata.revertDisplayServiceKey(null).getDisplayServiceKey(),"null:null");
|
||||||
assertEquals(BaseServiceMetadata.revertDisplayServiceKey("org.apache.dubbo.common.TestInterface:1.0.0:1").getDisplayServiceKey(),"null:null");
|
assertEquals(BaseServiceMetadata.revertDisplayServiceKey("org.apache.dubbo.common.TestInterface:1.0.0:1").getDisplayServiceKey(),"null:null");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -32,7 +32,7 @@ import org.junit.jupiter.api.Test;
|
||||||
/**
|
/**
|
||||||
* {@link CommonScopeModelInitializer}
|
* {@link CommonScopeModelInitializer}
|
||||||
*/
|
*/
|
||||||
public class CommonScopeModelInitializerTest {
|
class CommonScopeModelInitializerTest {
|
||||||
|
|
||||||
private FrameworkModel frameworkModel;
|
private FrameworkModel frameworkModel;
|
||||||
private ApplicationModel applicationModel;
|
private ApplicationModel applicationModel;
|
||||||
|
|
@ -51,7 +51,7 @@ public class CommonScopeModelInitializerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
void test() {
|
||||||
ScopeBeanFactory applicationModelBeanFactory = applicationModel.getBeanFactory();
|
ScopeBeanFactory applicationModelBeanFactory = applicationModel.getBeanFactory();
|
||||||
Assertions.assertNotNull(applicationModelBeanFactory.getBean(ShutdownHookCallbacks.class));
|
Assertions.assertNotNull(applicationModelBeanFactory.getBean(ShutdownHookCallbacks.class));
|
||||||
Assertions.assertNotNull(applicationModelBeanFactory.getBean(FrameworkStatusReportService.class));
|
Assertions.assertNotNull(applicationModelBeanFactory.getBean(FrameworkStatusReportService.class));
|
||||||
|
|
@ -60,4 +60,4 @@ public class CommonScopeModelInitializerTest {
|
||||||
ScopeBeanFactory moduleModelBeanFactory = moduleModel.getBeanFactory();
|
ScopeBeanFactory moduleModelBeanFactory = moduleModel.getBeanFactory();
|
||||||
Assertions.assertNotNull(moduleModelBeanFactory.getBean(ConfigurationCache.class));
|
Assertions.assertNotNull(moduleModelBeanFactory.getBean(ConfigurationCache.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -27,13 +27,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||||
|
|
||||||
public class InterfaceAddressURLTest {
|
class InterfaceAddressURLTest {
|
||||||
private static final String rawURL = "dubbo://10.20.130.230:20880/context/path?version=1.0.0&group=g1&application=provider&timeout=1000&category=provider&side=provider&sayHello.weight=222";
|
private static final String rawURL = "dubbo://10.20.130.230:20880/context/path?version=1.0.0&group=g1&application=provider&timeout=1000&category=provider&side=provider&sayHello.weight=222";
|
||||||
private static final URL overrideURL = URL.valueOf("override://10.20.130.230:20880/context/path?version=1.0.0&application=morgan&timeout=2000&category=configurators&sayHello.overrideKey=override");
|
private static final URL overrideURL = URL.valueOf("override://10.20.130.230:20880/context/path?version=1.0.0&application=morgan&timeout=2000&category=configurators&sayHello.overrideKey=override");
|
||||||
private static final URL consumerURL = URL.valueOf("consumer://10.20.130.230/context/path?version=2.0.0,1.0.0&group=g2&application=morgan&timeout=3000&side=consumer&sayHello.timeout=5000");
|
private static final URL consumerURL = URL.valueOf("consumer://10.20.130.230/context/path?version=2.0.0,1.0.0&group=g2&application=morgan&timeout=3000&side=consumer&sayHello.timeout=5000");
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMergeOverriden() {
|
void testMergeOverriden() {
|
||||||
URL url = URL.valueOf(rawURL);
|
URL url = URL.valueOf(rawURL);
|
||||||
ServiceAddressURL interfaceAddressURL = new DubboServiceAddressURL(url.getUrlAddress(), url.getUrlParam(), null, null);
|
ServiceAddressURL interfaceAddressURL = new DubboServiceAddressURL(url.getUrlAddress(), url.getUrlParam(), null, null);
|
||||||
assertEquals("1000", interfaceAddressURL.getParameter(TIMEOUT_KEY));
|
assertEquals("1000", interfaceAddressURL.getParameter(TIMEOUT_KEY));
|
||||||
|
|
@ -46,7 +46,7 @@ public class InterfaceAddressURLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetParameter() {
|
void testGetParameter() {
|
||||||
URL url = URL.valueOf(rawURL);
|
URL url = URL.valueOf(rawURL);
|
||||||
ServiceAddressURL interfaceAddressURL = new DubboServiceAddressURL(url.getUrlAddress(), url.getUrlParam(), consumerURL, null);
|
ServiceAddressURL interfaceAddressURL = new DubboServiceAddressURL(url.getUrlAddress(), url.getUrlParam(), consumerURL, null);
|
||||||
|
|
||||||
|
|
@ -64,7 +64,7 @@ public class InterfaceAddressURLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetMethodParameter() {
|
void testGetMethodParameter() {
|
||||||
URL url = URL.valueOf(rawURL);
|
URL url = URL.valueOf(rawURL);
|
||||||
ServiceAddressURL interfaceAddressURL = new DubboServiceAddressURL(url.getUrlAddress(), url.getUrlParam(), consumerURL, (ServiceConfigURL) overrideURL);
|
ServiceAddressURL interfaceAddressURL = new DubboServiceAddressURL(url.getUrlAddress(), url.getUrlParam(), consumerURL, (ServiceConfigURL) overrideURL);
|
||||||
|
|
||||||
|
|
@ -76,7 +76,7 @@ public class InterfaceAddressURLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testURLEquals() {
|
void testURLEquals() {
|
||||||
URL url1 = URL.valueOf(rawURL);
|
URL url1 = URL.valueOf(rawURL);
|
||||||
URL url2 = URL.valueOf(rawURL);
|
URL url2 = URL.valueOf(rawURL);
|
||||||
assertNotSame(url1, url2);
|
assertNotSame(url1, url2);
|
||||||
|
|
@ -95,7 +95,7 @@ public class InterfaceAddressURLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testToString() {
|
void testToString() {
|
||||||
URL url1 = URL.valueOf(rawURL);
|
URL url1 = URL.valueOf(rawURL);
|
||||||
System.out.println(url1.toString());
|
System.out.println(url1.toString());
|
||||||
ServiceAddressURL withConsumer = new DubboServiceAddressURL(url1.getUrlAddress(), url1.getUrlParam(), consumerURL, null);
|
ServiceAddressURL withConsumer = new DubboServiceAddressURL(url1.getUrlAddress(), url1.getUrlParam(), consumerURL, null);
|
||||||
|
|
@ -103,4 +103,4 @@ public class InterfaceAddressURLTest {
|
||||||
ServiceAddressURL withOverride2 = new DubboServiceAddressURL(url1.getUrlAddress(), url1.getUrlParam(), consumerURL, (ServiceConfigURL) overrideURL);
|
ServiceAddressURL withOverride2 = new DubboServiceAddressURL(url1.getUrlAddress(), url1.getUrlParam(), consumerURL, (ServiceConfigURL) overrideURL);
|
||||||
System.out.println(withOverride2.toString());
|
System.out.println(withOverride2.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -20,10 +20,10 @@ import org.apache.dubbo.common.utils.PojoUtils;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class PojoUtilsForNonPublicStaticTest {
|
class PojoUtilsForNonPublicStaticTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNonPublicStaticClass() {
|
void testNonPublicStaticClass() {
|
||||||
NonPublicStaticData nonPublicStaticData = new NonPublicStaticData("horizon");
|
NonPublicStaticData nonPublicStaticData = new NonPublicStaticData("horizon");
|
||||||
PojoUtils.generalize(nonPublicStaticData);
|
PojoUtils.generalize(nonPublicStaticData);
|
||||||
}
|
}
|
||||||
|
|
@ -47,4 +47,4 @@ public class PojoUtilsForNonPublicStaticTest {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -19,10 +19,10 @@ package org.apache.dubbo.common;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class ProtocolServiceKeyMatcherTest {
|
class ProtocolServiceKeyMatcherTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testProtocol() {
|
void testProtocol() {
|
||||||
Assertions.assertTrue(ProtocolServiceKey.Matcher.isMatch(
|
Assertions.assertTrue(ProtocolServiceKey.Matcher.isMatch(
|
||||||
new ProtocolServiceKey(null, null, null, "dubbo"),
|
new ProtocolServiceKey(null, null, null, "dubbo"),
|
||||||
new ProtocolServiceKey(null, null, null, "dubbo")
|
new ProtocolServiceKey(null, null, null, "dubbo")
|
||||||
|
|
@ -104,4 +104,4 @@ public class ProtocolServiceKeyMatcherTest {
|
||||||
new ProtocolServiceKey(null, null, null, "dubbo")
|
new ProtocolServiceKey(null, null, null, "dubbo")
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -19,9 +19,9 @@ package org.apache.dubbo.common;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class ProtocolServiceKeyTest {
|
class ProtocolServiceKeyTest {
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
void test() {
|
||||||
ProtocolServiceKey protocolServiceKey = new ProtocolServiceKey("DemoService", "1.0.0", "group1", "protocol1");
|
ProtocolServiceKey protocolServiceKey = new ProtocolServiceKey("DemoService", "1.0.0", "group1", "protocol1");
|
||||||
Assertions.assertEquals("DemoService", protocolServiceKey.getInterfaceName());
|
Assertions.assertEquals("DemoService", protocolServiceKey.getInterfaceName());
|
||||||
Assertions.assertEquals("1.0.0", protocolServiceKey.getVersion());
|
Assertions.assertEquals("1.0.0", protocolServiceKey.getVersion());
|
||||||
|
|
@ -73,4 +73,4 @@ public class ProtocolServiceKeyTest {
|
||||||
Assertions.assertFalse(protocolServiceKey7.isSameWith(new ProtocolServiceKey("DemoService", "1.0.0", "group1", "protocol1")));
|
Assertions.assertFalse(protocolServiceKey7.isSameWith(new ProtocolServiceKey("DemoService", "1.0.0", "group1", "protocol1")));
|
||||||
Assertions.assertFalse(protocolServiceKey7.isSameWith(new ProtocolServiceKey("DemoService", "1.0.0", "group1", "protocol2")));
|
Assertions.assertFalse(protocolServiceKey7.isSameWith(new ProtocolServiceKey("DemoService", "1.0.0", "group1", "protocol2")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -19,10 +19,10 @@ package org.apache.dubbo.common;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class ServiceKeyMatcherTest {
|
class ServiceKeyMatcherTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInterface() {
|
void testInterface() {
|
||||||
Assertions.assertTrue(ServiceKey.Matcher.isMatch(
|
Assertions.assertTrue(ServiceKey.Matcher.isMatch(
|
||||||
new ServiceKey(null, null, null),
|
new ServiceKey(null, null, null),
|
||||||
new ServiceKey(null, null, null)
|
new ServiceKey(null, null, null)
|
||||||
|
|
@ -48,7 +48,7 @@ public class ServiceKeyMatcherTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testVersion() {
|
void testVersion() {
|
||||||
Assertions.assertTrue(ServiceKey.Matcher.isMatch(
|
Assertions.assertTrue(ServiceKey.Matcher.isMatch(
|
||||||
new ServiceKey(null, "1.0.0", null),
|
new ServiceKey(null, "1.0.0", null),
|
||||||
new ServiceKey(null, "1.0.0", null)
|
new ServiceKey(null, "1.0.0", null)
|
||||||
|
|
@ -142,7 +142,7 @@ public class ServiceKeyMatcherTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGroup() {
|
void testGroup() {
|
||||||
Assertions.assertTrue(ServiceKey.Matcher.isMatch(
|
Assertions.assertTrue(ServiceKey.Matcher.isMatch(
|
||||||
new ServiceKey(null, null, "group1"),
|
new ServiceKey(null, null, "group1"),
|
||||||
new ServiceKey(null, null, "group1")
|
new ServiceKey(null, null, "group1")
|
||||||
|
|
@ -221,4 +221,4 @@ public class ServiceKeyMatcherTest {
|
||||||
new ServiceKey(null, null, "group1")
|
new ServiceKey(null, null, "group1")
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -19,9 +19,9 @@ package org.apache.dubbo.common;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class ServiceKeyTest {
|
class ServiceKeyTest {
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
void test() {
|
||||||
ServiceKey serviceKey = new ServiceKey("DemoService", "1.0.0", "group1");
|
ServiceKey serviceKey = new ServiceKey("DemoService", "1.0.0", "group1");
|
||||||
|
|
||||||
Assertions.assertEquals("DemoService", serviceKey.getInterfaceName());
|
Assertions.assertEquals("DemoService", serviceKey.getInterfaceName());
|
||||||
|
|
@ -51,4 +51,4 @@ public class ServiceKeyTest {
|
||||||
ProtocolServiceKey protocolServiceKey = new ProtocolServiceKey("DemoService", "1.0.0", "group1", "protocol1");
|
ProtocolServiceKey protocolServiceKey = new ProtocolServiceKey("DemoService", "1.0.0", "group1", "protocol1");
|
||||||
Assertions.assertNotEquals(serviceKey, protocolServiceKey);
|
Assertions.assertNotEquals(serviceKey, protocolServiceKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -27,15 +27,15 @@ import java.util.Map;
|
||||||
import static org.hamcrest.CoreMatchers.equalTo;
|
import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
|
||||||
public class URLBuilderTest {
|
class URLBuilderTest {
|
||||||
@Test
|
@Test
|
||||||
public void testNoArgConstructor() {
|
void testNoArgConstructor() {
|
||||||
URL url = new URLBuilder().build();
|
URL url = new URLBuilder().build();
|
||||||
assertThat(url.toString(), equalTo(""));
|
assertThat(url.toString(), equalTo(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldAddParameter() {
|
void shouldAddParameter() {
|
||||||
URL url1 = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
URL url1 = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
||||||
URL url2 = URLBuilder.from(url1)
|
URL url2 = URLBuilder.from(url1)
|
||||||
.addParameter("newKey1", "newValue1") // string
|
.addParameter("newKey1", "newValue1") // string
|
||||||
|
|
@ -48,7 +48,7 @@ public class URLBuilderTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldSet() {
|
void shouldSet() {
|
||||||
URL url1 = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
URL url1 = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
||||||
int port = NetUtils.getAvailablePort();
|
int port = NetUtils.getAvailablePort();
|
||||||
URL url2 = URLBuilder.from(url1)
|
URL url2 = URLBuilder.from(url1)
|
||||||
|
|
@ -75,7 +75,7 @@ public class URLBuilderTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldClearParameters() {
|
void shouldClearParameters() {
|
||||||
URL url1 = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
URL url1 = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
||||||
URL url2 = URLBuilder.from(url1)
|
URL url2 = URLBuilder.from(url1)
|
||||||
.clearParameters()
|
.clearParameters()
|
||||||
|
|
@ -84,7 +84,7 @@ public class URLBuilderTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldRemoveParameters() {
|
void shouldRemoveParameters() {
|
||||||
URL url1 = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan&key2=v2");
|
URL url1 = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan&key2=v2");
|
||||||
URL url2 = URLBuilder.from(url1)
|
URL url2 = URLBuilder.from(url1)
|
||||||
.removeParameters(Arrays.asList("key2", "application"))
|
.removeParameters(Arrays.asList("key2", "application"))
|
||||||
|
|
@ -94,7 +94,7 @@ public class URLBuilderTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldAddIfAbsent() {
|
void shouldAddIfAbsent() {
|
||||||
URL url1 = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan&key2=v2");
|
URL url1 = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan&key2=v2");
|
||||||
URL url2 = URLBuilder.from(url1)
|
URL url2 = URLBuilder.from(url1)
|
||||||
.addParameterIfAbsent("absentKey", "absentValue")
|
.addParameterIfAbsent("absentKey", "absentValue")
|
||||||
|
|
@ -105,7 +105,7 @@ public class URLBuilderTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldAddParameters() {
|
void shouldAddParameters() {
|
||||||
URL url1 = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan&key2=v2");
|
URL url1 = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan&key2=v2");
|
||||||
|
|
||||||
// string pairs test
|
// string pairs test
|
||||||
|
|
@ -130,7 +130,7 @@ public class URLBuilderTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldAddParametersIfAbsent() {
|
void shouldAddParametersIfAbsent() {
|
||||||
URL url1 = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan&key2=v2");
|
URL url1 = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan&key2=v2");
|
||||||
|
|
||||||
Map<String, String> parameters = new HashMap<String, String>(){
|
Map<String, String> parameters = new HashMap<String, String>(){
|
||||||
|
|
@ -145,4 +145,4 @@ public class URLBuilderTest {
|
||||||
assertThat(url2.getParameter("version"), equalTo("1.0.0"));
|
assertThat(url2.getParameter("version"), equalTo("1.0.0"));
|
||||||
assertThat(url2.getParameter("absentKey"), equalTo("absentValue"));
|
assertThat(url2.getParameter("absentKey"), equalTo("absentValue"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -29,7 +29,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
/**
|
/**
|
||||||
* Created by LinShunkang on 2020/03/12
|
* Created by LinShunkang on 2020/03/12
|
||||||
*/
|
*/
|
||||||
public class URLStrParserTest {
|
class URLStrParserTest {
|
||||||
private static Set<String> testCases = new HashSet<>(16);
|
private static Set<String> testCases = new HashSet<>(16);
|
||||||
private static Set<String> errorDecodedCases = new HashSet<>(8);
|
private static Set<String> errorDecodedCases = new HashSet<>(8);
|
||||||
private static Set<String> errorEncodedCases = new HashSet<>(8);
|
private static Set<String> errorEncodedCases = new HashSet<>(8);
|
||||||
|
|
@ -57,7 +57,7 @@ public class URLStrParserTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEncoded() {
|
void testEncoded() {
|
||||||
testCases.forEach(testCase -> {
|
testCases.forEach(testCase -> {
|
||||||
assertThat(URLStrParser.parseEncodedStr(URL.encode(testCase)), equalTo(URL.valueOf(testCase)));
|
assertThat(URLStrParser.parseEncodedStr(URL.encode(testCase)), equalTo(URL.valueOf(testCase)));
|
||||||
});
|
});
|
||||||
|
|
@ -69,7 +69,7 @@ public class URLStrParserTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecoded() {
|
void testDecoded() {
|
||||||
testCases.forEach(testCase -> {
|
testCases.forEach(testCase -> {
|
||||||
assertThat(URLStrParser.parseDecodedStr(testCase), equalTo(URL.valueOf(testCase)));
|
assertThat(URLStrParser.parseDecodedStr(testCase), equalTo(URL.valueOf(testCase)));
|
||||||
});
|
});
|
||||||
|
|
@ -80,4 +80,4 @@ public class URLStrParserTest {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -18,6 +18,7 @@ package org.apache.dubbo.common;
|
||||||
|
|
||||||
import org.apache.dubbo.common.url.component.ServiceConfigURL;
|
import org.apache.dubbo.common.url.component.ServiceConfigURL;
|
||||||
import org.apache.dubbo.common.utils.CollectionUtils;
|
import org.apache.dubbo.common.utils.CollectionUtils;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
|
@ -40,10 +41,10 @@ import static org.junit.jupiter.api.Assertions.assertSame;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
public class URLTest {
|
class URLTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_ignore_pond() {
|
void test_ignore_pond() {
|
||||||
URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path#index?version=1.0.0&id=org.apache.dubbo.config.RegistryConfig#0");
|
URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path#index?version=1.0.0&id=org.apache.dubbo.config.RegistryConfig#0");
|
||||||
assertURLStrDecoder(url);
|
assertURLStrDecoder(url);
|
||||||
assertEquals("dubbo", url.getProtocol());
|
assertEquals("dubbo", url.getProtocol());
|
||||||
|
|
@ -59,7 +60,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_valueOf_noProtocolAndHost() throws Exception {
|
void test_valueOf_noProtocolAndHost() throws Exception {
|
||||||
URL url = URL.valueOf("/context/path?version=1.0.0&application=morgan");
|
URL url = URL.valueOf("/context/path?version=1.0.0&application=morgan");
|
||||||
assertURLStrDecoder(url);
|
assertURLStrDecoder(url);
|
||||||
assertNull(url.getProtocol());
|
assertNull(url.getProtocol());
|
||||||
|
|
@ -97,7 +98,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_valueOf_noProtocol() throws Exception {
|
void test_valueOf_noProtocol() throws Exception {
|
||||||
URL url = URL.valueOf("10.20.130.230");
|
URL url = URL.valueOf("10.20.130.230");
|
||||||
assertURLStrDecoder(url);
|
assertURLStrDecoder(url);
|
||||||
assertNull(url.getProtocol());
|
assertNull(url.getProtocol());
|
||||||
|
|
@ -157,7 +158,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_valueOf_noHost() throws Exception {
|
void test_valueOf_noHost() throws Exception {
|
||||||
URL url = URL.valueOf("file:///home/user1/router.js");
|
URL url = URL.valueOf("file:///home/user1/router.js");
|
||||||
assertURLStrDecoder(url);
|
assertURLStrDecoder(url);
|
||||||
assertEquals("file", url.getProtocol());
|
assertEquals("file", url.getProtocol());
|
||||||
|
|
@ -236,7 +237,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_valueOf_WithProtocolHost() throws Exception {
|
void test_valueOf_WithProtocolHost() throws Exception {
|
||||||
URL url = URL.valueOf("dubbo://10.20.130.230");
|
URL url = URL.valueOf("dubbo://10.20.130.230");
|
||||||
assertURLStrDecoder(url);
|
assertURLStrDecoder(url);
|
||||||
assertEquals("dubbo", url.getProtocol());
|
assertEquals("dubbo", url.getProtocol());
|
||||||
|
|
@ -312,7 +313,7 @@ public class URLTest {
|
||||||
|
|
||||||
// TODO Do not want to use spaces? See: DUBBO-502, URL class handles special conventions for special characters.
|
// TODO Do not want to use spaces? See: DUBBO-502, URL class handles special conventions for special characters.
|
||||||
@Test
|
@Test
|
||||||
public void test_valueOf_spaceSafe() throws Exception {
|
void test_valueOf_spaceSafe() throws Exception {
|
||||||
URL url = URL.valueOf("http://1.2.3.4:8080/path?key=value1 value2");
|
URL url = URL.valueOf("http://1.2.3.4:8080/path?key=value1 value2");
|
||||||
assertURLStrDecoder(url);
|
assertURLStrDecoder(url);
|
||||||
assertEquals("http://1.2.3.4:8080/path?key=value1 value2", url.toString());
|
assertEquals("http://1.2.3.4:8080/path?key=value1 value2", url.toString());
|
||||||
|
|
@ -320,7 +321,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_noValueKey() throws Exception {
|
void test_noValueKey() throws Exception {
|
||||||
URL url = URL.valueOf("http://1.2.3.4:8080/path?k0=&k1=v1");
|
URL url = URL.valueOf("http://1.2.3.4:8080/path?k0=&k1=v1");
|
||||||
|
|
||||||
assertURLStrDecoder(url);
|
assertURLStrDecoder(url);
|
||||||
|
|
@ -331,7 +332,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_valueOf_Exception_noProtocol() throws Exception {
|
void test_valueOf_Exception_noProtocol() throws Exception {
|
||||||
try {
|
try {
|
||||||
URL.valueOf("://1.2.3.4:8080/path");
|
URL.valueOf("://1.2.3.4:8080/path");
|
||||||
fail();
|
fail();
|
||||||
|
|
@ -356,14 +357,14 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_getAddress() throws Exception {
|
void test_getAddress() throws Exception {
|
||||||
URL url1 = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
URL url1 = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
||||||
assertURLStrDecoder(url1);
|
assertURLStrDecoder(url1);
|
||||||
assertEquals("10.20.130.230:20880", url1.getAddress());
|
assertEquals("10.20.130.230:20880", url1.getAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_getAbsolutePath() throws Exception {
|
void test_getAbsolutePath() throws Exception {
|
||||||
URL url = new ServiceConfigURL("p1", "1.2.2.2", 33);
|
URL url = new ServiceConfigURL("p1", "1.2.2.2", 33);
|
||||||
assertURLStrDecoder(url);
|
assertURLStrDecoder(url);
|
||||||
assertNull(url.getAbsolutePath());
|
assertNull(url.getAbsolutePath());
|
||||||
|
|
@ -374,7 +375,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_equals() throws Exception {
|
void test_equals() throws Exception {
|
||||||
URL url1 = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
URL url1 = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
||||||
assertURLStrDecoder(url1);
|
assertURLStrDecoder(url1);
|
||||||
|
|
||||||
|
|
@ -388,7 +389,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_toString() throws Exception {
|
void test_toString() throws Exception {
|
||||||
URL url1 = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
URL url1 = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
||||||
assertURLStrDecoder(url1);
|
assertURLStrDecoder(url1);
|
||||||
assertThat(url1.toString(), anyOf(
|
assertThat(url1.toString(), anyOf(
|
||||||
|
|
@ -398,7 +399,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_toFullString() throws Exception {
|
void test_toFullString() throws Exception {
|
||||||
URL url1 = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
URL url1 = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
||||||
assertURLStrDecoder(url1);
|
assertURLStrDecoder(url1);
|
||||||
assertThat(url1.toFullString(), anyOf(
|
assertThat(url1.toFullString(), anyOf(
|
||||||
|
|
@ -408,7 +409,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_set_methods() throws Exception {
|
void test_set_methods() throws Exception {
|
||||||
URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
||||||
assertURLStrDecoder(url);
|
assertURLStrDecoder(url);
|
||||||
|
|
||||||
|
|
@ -498,7 +499,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_removeParameters() throws Exception {
|
void test_removeParameters() throws Exception {
|
||||||
URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan&k1=v1&k2=v2");
|
URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan&k1=v1&k2=v2");
|
||||||
assertURLStrDecoder(url);
|
assertURLStrDecoder(url);
|
||||||
|
|
||||||
|
|
@ -551,7 +552,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_addParameter() throws Exception {
|
void test_addParameter() throws Exception {
|
||||||
URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?application=morgan");
|
URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?application=morgan");
|
||||||
url = url.addParameter("k1", "v1");
|
url = url.addParameter("k1", "v1");
|
||||||
|
|
||||||
|
|
@ -569,7 +570,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_addParameter_sameKv() throws Exception {
|
void test_addParameter_sameKv() throws Exception {
|
||||||
URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?application=morgan&k1=v1");
|
URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?application=morgan&k1=v1");
|
||||||
URL newUrl = url.addParameter("k1", "v1");
|
URL newUrl = url.addParameter("k1", "v1");
|
||||||
|
|
||||||
|
|
@ -579,7 +580,7 @@ public class URLTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_addParameters() throws Exception {
|
void test_addParameters() throws Exception {
|
||||||
URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?application=morgan");
|
URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?application=morgan");
|
||||||
url = url.addParameters(CollectionUtils.toStringMap("k1", "v1", "k2", "v2"));
|
url = url.addParameters(CollectionUtils.toStringMap("k1", "v1", "k2", "v2"));
|
||||||
|
|
||||||
|
|
@ -659,7 +660,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_addParameters_SameKv() throws Exception {
|
void test_addParameters_SameKv() throws Exception {
|
||||||
{
|
{
|
||||||
URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?application=morgan&k1=v1");
|
URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?application=morgan&k1=v1");
|
||||||
URL newUrl = url.addParameters(CollectionUtils.toStringMap("k1", "v1"));
|
URL newUrl = url.addParameters(CollectionUtils.toStringMap("k1", "v1"));
|
||||||
|
|
@ -677,7 +678,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_addParameterIfAbsent() throws Exception {
|
void test_addParameterIfAbsent() throws Exception {
|
||||||
URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?application=morgan");
|
URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?application=morgan");
|
||||||
url = url.addParameterIfAbsent("application", "xxx");
|
url = url.addParameterIfAbsent("application", "xxx");
|
||||||
|
|
||||||
|
|
@ -694,7 +695,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_windowAbsolutePathBeginWithSlashIsValid() throws Exception {
|
void test_windowAbsolutePathBeginWithSlashIsValid() throws Exception {
|
||||||
final String osProperty = System.getProperties().getProperty(OS_NAME_KEY);
|
final String osProperty = System.getProperties().getProperty(OS_NAME_KEY);
|
||||||
if (!osProperty.toLowerCase().contains(OS_WIN_PREFIX)) return;
|
if (!osProperty.toLowerCase().contains(OS_WIN_PREFIX)) return;
|
||||||
|
|
||||||
|
|
@ -714,7 +715,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_javaNetUrl() throws Exception {
|
void test_javaNetUrl() throws Exception {
|
||||||
java.net.URL url = new java.net.URL("http://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan#anchor1");
|
java.net.URL url = new java.net.URL("http://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan#anchor1");
|
||||||
|
|
||||||
assertEquals("http", url.getProtocol());
|
assertEquals("http", url.getProtocol());
|
||||||
|
|
@ -730,7 +731,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_Anyhost() throws Exception {
|
void test_Anyhost() throws Exception {
|
||||||
URL url = URL.valueOf("dubbo://0.0.0.0:20880");
|
URL url = URL.valueOf("dubbo://0.0.0.0:20880");
|
||||||
assertURLStrDecoder(url);
|
assertURLStrDecoder(url);
|
||||||
assertEquals("0.0.0.0", url.getHost());
|
assertEquals("0.0.0.0", url.getHost());
|
||||||
|
|
@ -738,7 +739,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_Localhost() throws Exception {
|
void test_Localhost() throws Exception {
|
||||||
URL url = URL.valueOf("dubbo://127.0.0.1:20880");
|
URL url = URL.valueOf("dubbo://127.0.0.1:20880");
|
||||||
assertURLStrDecoder(url);
|
assertURLStrDecoder(url);
|
||||||
assertEquals("127.0.0.1", url.getHost());
|
assertEquals("127.0.0.1", url.getHost());
|
||||||
|
|
@ -759,14 +760,14 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_Path() throws Exception {
|
void test_Path() throws Exception {
|
||||||
URL url = new ServiceConfigURL("dubbo", "localhost", 20880, "////path");
|
URL url = new ServiceConfigURL("dubbo", "localhost", 20880, "////path");
|
||||||
assertURLStrDecoder(url);
|
assertURLStrDecoder(url);
|
||||||
assertEquals("path", url.getPath());
|
assertEquals("path", url.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddParameters() throws Exception {
|
void testAddParameters() throws Exception {
|
||||||
URL url = URL.valueOf("dubbo://127.0.0.1:20880");
|
URL url = URL.valueOf("dubbo://127.0.0.1:20880");
|
||||||
assertURLStrDecoder(url);
|
assertURLStrDecoder(url);
|
||||||
|
|
||||||
|
|
@ -777,7 +778,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUserNamePasswordContainsAt() {
|
void testUserNamePasswordContainsAt() {
|
||||||
// Test username or password contains "@"
|
// Test username or password contains "@"
|
||||||
URL url = URL.valueOf("ad@min:hello@1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
URL url = URL.valueOf("ad@min:hello@1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
||||||
assertURLStrDecoder(url);
|
assertURLStrDecoder(url);
|
||||||
|
|
@ -795,7 +796,7 @@ public class URLTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIpV6Address() {
|
void testIpV6Address() {
|
||||||
// Test username or password contains "@"
|
// Test username or password contains "@"
|
||||||
URL url = URL.valueOf("ad@min111:haha@1234@2001:0db8:85a3:08d3:1319:8a2e:0370:7344:20880/context/path?version=1.0.0&application=morgan");
|
URL url = URL.valueOf("ad@min111:haha@1234@2001:0db8:85a3:08d3:1319:8a2e:0370:7344:20880/context/path?version=1.0.0&application=morgan");
|
||||||
assertURLStrDecoder(url);
|
assertURLStrDecoder(url);
|
||||||
|
|
@ -812,7 +813,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIpV6AddressWithScopeId() {
|
void testIpV6AddressWithScopeId() {
|
||||||
URL url = URL.valueOf("2001:0db8:85a3:08d3:1319:8a2e:0370:7344%5/context/path?version=1.0.0&application=morgan");
|
URL url = URL.valueOf("2001:0db8:85a3:08d3:1319:8a2e:0370:7344%5/context/path?version=1.0.0&application=morgan");
|
||||||
assertURLStrDecoder(url);
|
assertURLStrDecoder(url);
|
||||||
assertNull(url.getProtocol());
|
assertNull(url.getProtocol());
|
||||||
|
|
@ -826,13 +827,13 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDefaultPort() {
|
void testDefaultPort() {
|
||||||
Assertions.assertEquals("10.20.153.10:2181", URL.appendDefaultPort("10.20.153.10:0", 2181));
|
Assertions.assertEquals("10.20.153.10:2181", URL.appendDefaultPort("10.20.153.10:0", 2181));
|
||||||
Assertions.assertEquals("10.20.153.10:2181", URL.appendDefaultPort("10.20.153.10", 2181));
|
Assertions.assertEquals("10.20.153.10:2181", URL.appendDefaultPort("10.20.153.10", 2181));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetServiceKey() {
|
void testGetServiceKey() {
|
||||||
URL url1 = URL.valueOf("10.20.130.230:20880/context/path?interface=org.apache.dubbo.test.interfaceName");
|
URL url1 = URL.valueOf("10.20.130.230:20880/context/path?interface=org.apache.dubbo.test.interfaceName");
|
||||||
assertURLStrDecoder(url1);
|
assertURLStrDecoder(url1);
|
||||||
Assertions.assertEquals("org.apache.dubbo.test.interfaceName", url1.getServiceKey());
|
Assertions.assertEquals("org.apache.dubbo.test.interfaceName", url1.getServiceKey());
|
||||||
|
|
@ -855,7 +856,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetColonSeparatedKey() {
|
void testGetColonSeparatedKey() {
|
||||||
URL url1 = URL.valueOf("10.20.130.230:20880/context/path?interface=org.apache.dubbo.test.interfaceName&group=group&version=1.0.0");
|
URL url1 = URL.valueOf("10.20.130.230:20880/context/path?interface=org.apache.dubbo.test.interfaceName&group=group&version=1.0.0");
|
||||||
assertURLStrDecoder(url1);
|
assertURLStrDecoder(url1);
|
||||||
Assertions.assertEquals("org.apache.dubbo.test.interfaceName:1.0.0:group", url1.getColonSeparatedKey());
|
Assertions.assertEquals("org.apache.dubbo.test.interfaceName:1.0.0:group", url1.getColonSeparatedKey());
|
||||||
|
|
@ -882,7 +883,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testValueOf() {
|
void testValueOf() {
|
||||||
URL url = URL.valueOf("10.20.130.230");
|
URL url = URL.valueOf("10.20.130.230");
|
||||||
assertURLStrDecoder(url);
|
assertURLStrDecoder(url);
|
||||||
|
|
||||||
|
|
@ -903,7 +904,7 @@ public class URLTest {
|
||||||
* @since 2.7.8
|
* @since 2.7.8
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetParameters() {
|
void testGetParameters() {
|
||||||
URL url = URL.valueOf("10.20.130.230:20880/context/path?interface=org.apache.dubbo.test.interfaceName&group=group&version=1.0.0");
|
URL url = URL.valueOf("10.20.130.230:20880/context/path?interface=org.apache.dubbo.test.interfaceName&group=group&version=1.0.0");
|
||||||
Map<String, String> parameters = url.getParameters(i -> "version".equals(i));
|
Map<String, String> parameters = url.getParameters(i -> "version".equals(i));
|
||||||
String version = parameters.get("version");
|
String version = parameters.get("version");
|
||||||
|
|
@ -912,14 +913,14 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetParameter() {
|
void testGetParameter() {
|
||||||
URL url = URL.valueOf("http://127.0.0.1:8080/path?i=1&b=false");
|
URL url = URL.valueOf("http://127.0.0.1:8080/path?i=1&b=false");
|
||||||
assertEquals(Integer.valueOf(1), url.getParameter("i", Integer.class));
|
assertEquals(Integer.valueOf(1), url.getParameter("i", Integer.class));
|
||||||
assertEquals(Boolean.FALSE, url.getParameter("b", Boolean.class));
|
assertEquals(Boolean.FALSE, url.getParameter("b", Boolean.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEquals() {
|
void testEquals() {
|
||||||
URL url1 = URL.valueOf("10.20.130.230:20880/context/path?interface=org.apache.dubbo.test.interfaceName&group=group&version=1.0.0");
|
URL url1 = URL.valueOf("10.20.130.230:20880/context/path?interface=org.apache.dubbo.test.interfaceName&group=group&version=1.0.0");
|
||||||
URL url2 = URL.valueOf("10.20.130.230:20880/context/path?interface=org.apache.dubbo.test.interfaceName&group=group&version=1.0.0");
|
URL url2 = URL.valueOf("10.20.130.230:20880/context/path?interface=org.apache.dubbo.test.interfaceName&group=group&version=1.0.0");
|
||||||
Assertions.assertEquals(url1, url2);
|
Assertions.assertEquals(url1, url2);
|
||||||
|
|
@ -955,7 +956,7 @@ public class URLTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEqualsWithPassword() {
|
void testEqualsWithPassword() {
|
||||||
URL url1 = URL.valueOf("ad@min:hello@1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
URL url1 = URL.valueOf("ad@min:hello@1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
||||||
URL url2 = URL.valueOf("ad@min:hello@4321@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
URL url2 = URL.valueOf("ad@min:hello@4321@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
||||||
URL url3 = URL.valueOf("ad@min:hello@1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
URL url3 = URL.valueOf("ad@min:hello@1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
||||||
|
|
@ -967,7 +968,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEqualsWithPath() {
|
void testEqualsWithPath() {
|
||||||
URL url1 = URL.valueOf("ad@min:hello@1234@10.20.130.230:20880/context/path1?version=1.0.0&application=morgan");
|
URL url1 = URL.valueOf("ad@min:hello@1234@10.20.130.230:20880/context/path1?version=1.0.0&application=morgan");
|
||||||
URL url2 = URL.valueOf("ad@min:hello@1234@10.20.130.230:20880/context/path2?version=1.0.0&application=morgan");
|
URL url2 = URL.valueOf("ad@min:hello@1234@10.20.130.230:20880/context/path2?version=1.0.0&application=morgan");
|
||||||
URL url3 = URL.valueOf("ad@min:hello@1234@10.20.130.230:20880/context/path1?version=1.0.0&application=morgan");
|
URL url3 = URL.valueOf("ad@min:hello@1234@10.20.130.230:20880/context/path1?version=1.0.0&application=morgan");
|
||||||
|
|
@ -979,7 +980,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEqualsWithPort() {
|
void testEqualsWithPort() {
|
||||||
URL url1 = URL.valueOf("ad@min:hello@1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
URL url1 = URL.valueOf("ad@min:hello@1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
||||||
URL url2 = URL.valueOf("ad@min:hello@1234@10.20.130.230:20881/context/path?version=1.0.0&application=morgan");
|
URL url2 = URL.valueOf("ad@min:hello@1234@10.20.130.230:20881/context/path?version=1.0.0&application=morgan");
|
||||||
URL url3 = URL.valueOf("ad@min:hello@1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
URL url3 = URL.valueOf("ad@min:hello@1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
||||||
|
|
@ -991,7 +992,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEqualsWithProtocol() {
|
void testEqualsWithProtocol() {
|
||||||
URL url1 = URL.valueOf("dubbo://ad@min:hello@1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
URL url1 = URL.valueOf("dubbo://ad@min:hello@1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
||||||
URL url2 = URL.valueOf("file://ad@min:hello@1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
URL url2 = URL.valueOf("file://ad@min:hello@1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
||||||
URL url3 = URL.valueOf("dubbo://ad@min:hello@1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
URL url3 = URL.valueOf("dubbo://ad@min:hello@1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
||||||
|
|
@ -1003,7 +1004,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEqualsWithUser() {
|
void testEqualsWithUser() {
|
||||||
URL url1 = URL.valueOf("ad@min1:hello@1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
URL url1 = URL.valueOf("ad@min1:hello@1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
||||||
URL url2 = URL.valueOf("ad@min2:hello@1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
URL url2 = URL.valueOf("ad@min2:hello@1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
||||||
URL url3 = URL.valueOf("ad@min1:hello@1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
URL url3 = URL.valueOf("ad@min1:hello@1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan");
|
||||||
|
|
@ -1015,7 +1016,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHashcode() {
|
void testHashcode() {
|
||||||
URL url1 = URL.valueOf("consumer://30.225.20.150/org.apache.dubbo.rpc.service.GenericService?application=" +
|
URL url1 = URL.valueOf("consumer://30.225.20.150/org.apache.dubbo.rpc.service.GenericService?application=" +
|
||||||
"dubbo-demo-api-consumer&category=consumers&check=false&dubbo=2.0.2&generic=true&interface=" +
|
"dubbo-demo-api-consumer&category=consumers&check=false&dubbo=2.0.2&generic=true&interface=" +
|
||||||
"org.apache.dubbo.demo.DemoService&pid=7375&side=consumer&sticky=false×tamp=1599556506417");
|
"org.apache.dubbo.demo.DemoService&pid=7375&side=consumer&sticky=false×tamp=1599556506417");
|
||||||
|
|
@ -1036,7 +1037,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParameterContainPound() {
|
void testParameterContainPound() {
|
||||||
URL url = URL.valueOf(
|
URL url = URL.valueOf(
|
||||||
"dubbo://ad@min:hello@1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan£=abcd#efg&protocol=registry");
|
"dubbo://ad@min:hello@1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan£=abcd#efg&protocol=registry");
|
||||||
Assertions.assertEquals("abcd#efg", url.getParameter("pound"));
|
Assertions.assertEquals("abcd#efg", url.getParameter("pound"));
|
||||||
|
|
@ -1044,13 +1045,13 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_valueOfHasNameWithoutValue() throws Exception {
|
void test_valueOfHasNameWithoutValue() throws Exception {
|
||||||
URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan&noValue");
|
URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=morgan&noValue");
|
||||||
Assertions.assertEquals("noValue", url.getParameter("noValue"));
|
Assertions.assertEquals("noValue", url.getParameter("noValue"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAuthority() {
|
void testGetAuthority() {
|
||||||
URL url = URL.valueOf("admin1:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=app1");
|
URL url = URL.valueOf("admin1:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=app1");
|
||||||
assertEquals("admin1:hello1234@10.20.130.230:20880", url.getAuthority());
|
assertEquals("admin1:hello1234@10.20.130.230:20880", url.getAuthority());
|
||||||
|
|
||||||
|
|
@ -1068,7 +1069,7 @@ public class URLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetUserInformation() {
|
void testGetUserInformation() {
|
||||||
URL url = URL.valueOf("admin1:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=app1");
|
URL url = URL.valueOf("admin1:hello1234@10.20.130.230:20880/context/path?version=1.0.0&application=app1");
|
||||||
assertEquals("admin1:hello1234", url.getUserInformation());
|
assertEquals("admin1:hello1234", url.getUserInformation());
|
||||||
|
|
||||||
|
|
@ -1084,7 +1085,7 @@ public class URLTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIPV6() {
|
void testIPV6() {
|
||||||
URL url = URL.valueOf("dubbo://[2408:4004:194:8896:3e8a:82ae:814a:398]:20881?name=apache");
|
URL url = URL.valueOf("dubbo://[2408:4004:194:8896:3e8a:82ae:814a:398]:20881?name=apache");
|
||||||
assertEquals("[2408:4004:194:8896:3e8a:82ae:814a:398]", url.getHost());
|
assertEquals("[2408:4004:194:8896:3e8a:82ae:814a:398]", url.getHost());
|
||||||
assertEquals(20881, url.getPort());
|
assertEquals(20881, url.getPort());
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ import org.apache.dubbo.rpc.model.ScopeModelAccessor;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class InstantiationStrategyTest {
|
class InstantiationStrategyTest {
|
||||||
|
|
||||||
private ScopeModelAccessor scopeModelAccessor = new ScopeModelAccessor() {
|
private ScopeModelAccessor scopeModelAccessor = new ScopeModelAccessor() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -41,7 +41,7 @@ public class InstantiationStrategyTest {
|
||||||
};
|
};
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateBeanWithScopeModelArgument() throws ReflectiveOperationException {
|
void testCreateBeanWithScopeModelArgument() throws ReflectiveOperationException {
|
||||||
InstantiationStrategy instantiationStrategy = new InstantiationStrategy(scopeModelAccessor);
|
InstantiationStrategy instantiationStrategy = new InstantiationStrategy(scopeModelAccessor);
|
||||||
|
|
||||||
FooBeanWithFrameworkModel beanWithFrameworkModel = instantiationStrategy.instantiate(FooBeanWithFrameworkModel.class);
|
FooBeanWithFrameworkModel beanWithFrameworkModel = instantiationStrategy.instantiate(FooBeanWithFrameworkModel.class);
|
||||||
|
|
@ -67,4 +67,4 @@ public class InstantiationStrategyTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -25,10 +25,10 @@ import org.apache.dubbo.rpc.model.FrameworkModel;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class ScopeBeanFactoryTest {
|
class ScopeBeanFactoryTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInjection() {
|
void testInjection() {
|
||||||
|
|
||||||
ApplicationModel applicationModel = ApplicationModel.defaultModel();
|
ApplicationModel applicationModel = ApplicationModel.defaultModel();
|
||||||
ScopeBeanFactory beanFactory = applicationModel.getBeanFactory();
|
ScopeBeanFactory beanFactory = applicationModel.getBeanFactory();
|
||||||
|
|
@ -54,4 +54,4 @@ public class ScopeBeanFactoryTest {
|
||||||
Assertions.assertTrue(beanWithApplicationModel.isDestroyed());
|
Assertions.assertTrue(beanWithApplicationModel.isDestroyed());
|
||||||
Assertions.assertTrue(beanWithFrameworkModel.isDestroyed());
|
Assertions.assertTrue(beanWithFrameworkModel.isDestroyed());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -19,19 +19,19 @@ package org.apache.dubbo.common.beanutil;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class JavaBeanAccessorTest {
|
class JavaBeanAccessorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsAccessByMethod(){
|
void testIsAccessByMethod(){
|
||||||
Assertions.assertTrue(JavaBeanAccessor.isAccessByMethod(JavaBeanAccessor.METHOD));
|
Assertions.assertTrue(JavaBeanAccessor.isAccessByMethod(JavaBeanAccessor.METHOD));
|
||||||
Assertions.assertTrue(JavaBeanAccessor.isAccessByMethod(JavaBeanAccessor.ALL));
|
Assertions.assertTrue(JavaBeanAccessor.isAccessByMethod(JavaBeanAccessor.ALL));
|
||||||
Assertions.assertFalse(JavaBeanAccessor.isAccessByMethod(JavaBeanAccessor.FIELD));
|
Assertions.assertFalse(JavaBeanAccessor.isAccessByMethod(JavaBeanAccessor.FIELD));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsAccessByField(){
|
void testIsAccessByField(){
|
||||||
Assertions.assertTrue(JavaBeanAccessor.isAccessByField(JavaBeanAccessor.FIELD));
|
Assertions.assertTrue(JavaBeanAccessor.isAccessByField(JavaBeanAccessor.FIELD));
|
||||||
Assertions.assertTrue(JavaBeanAccessor.isAccessByField(JavaBeanAccessor.ALL));
|
Assertions.assertTrue(JavaBeanAccessor.isAccessByField(JavaBeanAccessor.ALL));
|
||||||
Assertions.assertFalse(JavaBeanAccessor.isAccessByField(JavaBeanAccessor.METHOD));
|
Assertions.assertFalse(JavaBeanAccessor.isAccessByField(JavaBeanAccessor.METHOD));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -35,10 +35,10 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class JavaBeanSerializeUtilTest {
|
class JavaBeanSerializeUtilTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSerialize_Primitive() {
|
void testSerialize_Primitive() {
|
||||||
JavaBeanDescriptor descriptor;
|
JavaBeanDescriptor descriptor;
|
||||||
descriptor = JavaBeanSerializeUtil.serialize(Integer.MAX_VALUE);
|
descriptor = JavaBeanSerializeUtil.serialize(Integer.MAX_VALUE);
|
||||||
Assertions.assertTrue(descriptor.isPrimitiveType());
|
Assertions.assertTrue(descriptor.isPrimitiveType());
|
||||||
|
|
@ -51,14 +51,14 @@ public class JavaBeanSerializeUtilTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSerialize_Primitive_NUll() {
|
void testSerialize_Primitive_NUll() {
|
||||||
JavaBeanDescriptor descriptor;
|
JavaBeanDescriptor descriptor;
|
||||||
descriptor = JavaBeanSerializeUtil.serialize(null);
|
descriptor = JavaBeanSerializeUtil.serialize(null);
|
||||||
Assertions.assertNull(descriptor);
|
Assertions.assertNull(descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeserialize_Primitive() {
|
void testDeserialize_Primitive() {
|
||||||
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(), JavaBeanDescriptor.TYPE_PRIMITIVE);
|
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(), JavaBeanDescriptor.TYPE_PRIMITIVE);
|
||||||
descriptor.setPrimitiveProperty(Long.MAX_VALUE);
|
descriptor.setPrimitiveProperty(Long.MAX_VALUE);
|
||||||
Assertions.assertEquals(Long.MAX_VALUE, JavaBeanSerializeUtil.deserialize(descriptor));
|
Assertions.assertEquals(Long.MAX_VALUE, JavaBeanSerializeUtil.deserialize(descriptor));
|
||||||
|
|
@ -73,7 +73,7 @@ public class JavaBeanSerializeUtilTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeserialize_Primitive0() {
|
void testDeserialize_Primitive0() {
|
||||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||||
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(),
|
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(),
|
||||||
JavaBeanDescriptor.TYPE_BEAN + 1);
|
JavaBeanDescriptor.TYPE_BEAN + 1);
|
||||||
|
|
@ -81,14 +81,14 @@ public class JavaBeanSerializeUtilTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeserialize_Null() {
|
void testDeserialize_Null() {
|
||||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||||
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(null, JavaBeanDescriptor.TYPE_BEAN);
|
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(null, JavaBeanDescriptor.TYPE_BEAN);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeserialize_containsProperty() {
|
void testDeserialize_containsProperty() {
|
||||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||||
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(),
|
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(),
|
||||||
JavaBeanDescriptor.TYPE_PRIMITIVE);
|
JavaBeanDescriptor.TYPE_PRIMITIVE);
|
||||||
|
|
@ -97,7 +97,7 @@ public class JavaBeanSerializeUtilTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetEnumNameProperty() {
|
void testSetEnumNameProperty() {
|
||||||
Assertions.assertThrows(IllegalStateException.class, () -> {
|
Assertions.assertThrows(IllegalStateException.class, () -> {
|
||||||
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(),
|
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(),
|
||||||
JavaBeanDescriptor.TYPE_PRIMITIVE);
|
JavaBeanDescriptor.TYPE_PRIMITIVE);
|
||||||
|
|
@ -115,7 +115,7 @@ public class JavaBeanSerializeUtilTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetEnumNameProperty() {
|
void testGetEnumNameProperty() {
|
||||||
Assertions.assertThrows(IllegalStateException.class, () -> {
|
Assertions.assertThrows(IllegalStateException.class, () -> {
|
||||||
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(),
|
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(),
|
||||||
JavaBeanDescriptor.TYPE_PRIMITIVE);
|
JavaBeanDescriptor.TYPE_PRIMITIVE);
|
||||||
|
|
@ -124,7 +124,7 @@ public class JavaBeanSerializeUtilTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetClassNameProperty() {
|
void testSetClassNameProperty() {
|
||||||
|
|
||||||
Assertions.assertThrows(IllegalStateException.class, () -> {
|
Assertions.assertThrows(IllegalStateException.class, () -> {
|
||||||
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(),
|
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(),
|
||||||
|
|
@ -143,7 +143,7 @@ public class JavaBeanSerializeUtilTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetClassNameProperty() {
|
void testGetClassNameProperty() {
|
||||||
Assertions.assertThrows(IllegalStateException.class, () -> {
|
Assertions.assertThrows(IllegalStateException.class, () -> {
|
||||||
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(),
|
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(),
|
||||||
JavaBeanDescriptor.TYPE_PRIMITIVE);
|
JavaBeanDescriptor.TYPE_PRIMITIVE);
|
||||||
|
|
@ -152,7 +152,7 @@ public class JavaBeanSerializeUtilTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetPrimitiveProperty() {
|
void testSetPrimitiveProperty() {
|
||||||
Assertions.assertThrows(IllegalStateException.class, () -> {
|
Assertions.assertThrows(IllegalStateException.class, () -> {
|
||||||
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(JavaBeanDescriptor.class.getName(),
|
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(JavaBeanDescriptor.class.getName(),
|
||||||
JavaBeanDescriptor.TYPE_BEAN);
|
JavaBeanDescriptor.TYPE_BEAN);
|
||||||
|
|
@ -161,7 +161,7 @@ public class JavaBeanSerializeUtilTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetPrimitiveProperty() {
|
void testGetPrimitiveProperty() {
|
||||||
Assertions.assertThrows(IllegalStateException.class, () -> {
|
Assertions.assertThrows(IllegalStateException.class, () -> {
|
||||||
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(JavaBeanDescriptor.class.getName(),
|
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(JavaBeanDescriptor.class.getName(),
|
||||||
JavaBeanDescriptor.TYPE_BEAN);
|
JavaBeanDescriptor.TYPE_BEAN);
|
||||||
|
|
@ -170,7 +170,7 @@ public class JavaBeanSerializeUtilTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeserialize_get_and_set() {
|
void testDeserialize_get_and_set() {
|
||||||
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(), JavaBeanDescriptor.TYPE_BEAN);
|
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(long.class.getName(), JavaBeanDescriptor.TYPE_BEAN);
|
||||||
descriptor.setType(JavaBeanDescriptor.TYPE_PRIMITIVE);
|
descriptor.setType(JavaBeanDescriptor.TYPE_PRIMITIVE);
|
||||||
Assertions.assertEquals(descriptor.getType(), JavaBeanDescriptor.TYPE_PRIMITIVE);
|
Assertions.assertEquals(descriptor.getType(), JavaBeanDescriptor.TYPE_PRIMITIVE);
|
||||||
|
|
@ -179,7 +179,7 @@ public class JavaBeanSerializeUtilTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSerialize_Array() {
|
void testSerialize_Array() {
|
||||||
int[] array = {1, 2, 3, 4, 5, 6, 7, 8, 9};
|
int[] array = {1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||||
JavaBeanDescriptor descriptor = JavaBeanSerializeUtil.serialize(array, JavaBeanAccessor.METHOD);
|
JavaBeanDescriptor descriptor = JavaBeanSerializeUtil.serialize(array, JavaBeanAccessor.METHOD);
|
||||||
Assertions.assertTrue(descriptor.isArrayType());
|
Assertions.assertTrue(descriptor.isArrayType());
|
||||||
|
|
@ -226,7 +226,7 @@ public class JavaBeanSerializeUtilTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConstructorArg() {
|
void testConstructorArg() {
|
||||||
Assertions.assertFalse((boolean) JavaBeanSerializeUtil.getConstructorArg(boolean.class));
|
Assertions.assertFalse((boolean) JavaBeanSerializeUtil.getConstructorArg(boolean.class));
|
||||||
Assertions.assertFalse((boolean) JavaBeanSerializeUtil.getConstructorArg(Boolean.class));
|
Assertions.assertFalse((boolean) JavaBeanSerializeUtil.getConstructorArg(Boolean.class));
|
||||||
Assertions.assertEquals((byte) 0, JavaBeanSerializeUtil.getConstructorArg(byte.class));
|
Assertions.assertEquals((byte) 0, JavaBeanSerializeUtil.getConstructorArg(byte.class));
|
||||||
|
|
@ -247,7 +247,7 @@ public class JavaBeanSerializeUtilTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeserialize_Array() {
|
void testDeserialize_Array() {
|
||||||
final int len = 10;
|
final int len = 10;
|
||||||
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(int.class.getName(), JavaBeanDescriptor.TYPE_ARRAY);
|
JavaBeanDescriptor descriptor = new JavaBeanDescriptor(int.class.getName(), JavaBeanDescriptor.TYPE_ARRAY);
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
|
|
@ -299,7 +299,7 @@ public class JavaBeanSerializeUtilTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_Circular_Reference() {
|
void test_Circular_Reference() {
|
||||||
PojoUtilsTest.Parent parent = new PojoUtilsTest.Parent();
|
PojoUtilsTest.Parent parent = new PojoUtilsTest.Parent();
|
||||||
parent.setAge(Integer.MAX_VALUE);
|
parent.setAge(Integer.MAX_VALUE);
|
||||||
parent.setEmail("a@b");
|
parent.setEmail("a@b");
|
||||||
|
|
@ -325,7 +325,7 @@ public class JavaBeanSerializeUtilTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBeanSerialize() {
|
void testBeanSerialize() {
|
||||||
Bean bean = new Bean();
|
Bean bean = new Bean();
|
||||||
bean.setDate(new Date());
|
bean.setDate(new Date());
|
||||||
bean.setStatus(PersonStatus.ENABLED);
|
bean.setStatus(PersonStatus.ENABLED);
|
||||||
|
|
@ -375,7 +375,7 @@ public class JavaBeanSerializeUtilTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeserializeBean() {
|
void testDeserializeBean() {
|
||||||
Bean bean = new Bean();
|
Bean bean = new Bean();
|
||||||
bean.setDate(new Date());
|
bean.setDate(new Date());
|
||||||
bean.setStatus(PersonStatus.ENABLED);
|
bean.setStatus(PersonStatus.ENABLED);
|
||||||
|
|
@ -544,4 +544,4 @@ public class JavaBeanSerializeUtilTest {
|
||||||
bigPerson.setInfoProfile(pi);
|
bigPerson.setInfoProfile(pi);
|
||||||
return bigPerson;
|
return bigPerson;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -48,10 +48,10 @@ class BaseClass {
|
||||||
interface BaseInterface {
|
interface BaseInterface {
|
||||||
|
|
||||||
}
|
}
|
||||||
public class ClassGeneratorTest {
|
class ClassGeneratorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() throws Exception {
|
void test() throws Exception {
|
||||||
ClassGenerator cg = ClassGenerator.newInstance();
|
ClassGenerator cg = ClassGenerator.newInstance();
|
||||||
|
|
||||||
// add className, interface, superClass
|
// add className, interface, superClass
|
||||||
|
|
@ -147,7 +147,7 @@ public class ClassGeneratorTest {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Test
|
@Test
|
||||||
public void testMain() throws Exception {
|
void testMain() throws Exception {
|
||||||
Bean b = new Bean();
|
Bean b = new Bean();
|
||||||
Field fname = Bean.class.getDeclaredField("name");
|
Field fname = Bean.class.getDeclaredField("name");
|
||||||
fname.setAccessible(true);
|
fname.setAccessible(true);
|
||||||
|
|
@ -173,7 +173,7 @@ public class ClassGeneratorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMain0() throws Exception {
|
void testMain0() throws Exception {
|
||||||
Bean b = new Bean();
|
Bean b = new Bean();
|
||||||
Field fname = Bean.class.getDeclaredField("name");
|
Field fname = Bean.class.getDeclaredField("name");
|
||||||
fname.setAccessible(true);
|
fname.setAccessible(true);
|
||||||
|
|
@ -213,4 +213,4 @@ class Bean {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static volatile String abc = "df";
|
public static volatile String abc = "df";
|
||||||
}
|
}
|
||||||
|
|
@ -20,10 +20,10 @@ import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class MixinTest {
|
class MixinTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMain() throws Exception {
|
void testMain() throws Exception {
|
||||||
Mixin mixin = Mixin.mixin(new Class[]{I1.class, I2.class, I3.class}, new Class[]{C1.class, C2.class});
|
Mixin mixin = Mixin.mixin(new Class[]{I1.class, I2.class, I3.class}, new Class[]{C1.class, C2.class});
|
||||||
Object o = mixin.newInstance(new Object[]{new C1(), new C2()});
|
Object o = mixin.newInstance(new Object[]{new C1(), new C2()});
|
||||||
assertTrue(o instanceof I1);
|
assertTrue(o instanceof I1);
|
||||||
|
|
@ -69,4 +69,4 @@ public class MixinTest {
|
||||||
System.out.println("setMixinInstance:" + mi);
|
System.out.println("setMixinInstance:" + mi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -27,10 +27,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
@DisabledForJreRange(min = JRE.JAVA_16)
|
@DisabledForJreRange(min = JRE.JAVA_16)
|
||||||
public class ProxyTest {
|
class ProxyTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMain() throws Exception {
|
void testMain() throws Exception {
|
||||||
Proxy proxy = Proxy.getProxy(ITest.class, ITest.class);
|
Proxy proxy = Proxy.getProxy(ITest.class, ITest.class);
|
||||||
ITest instance = (ITest) proxy.newInstance((proxy1, method, args) -> {
|
ITest instance = (ITest) proxy.newInstance((proxy1, method, args) -> {
|
||||||
if ("getName".equals(method.getName())) {
|
if ("getName".equals(method.getName())) {
|
||||||
|
|
@ -48,7 +48,7 @@ public class ProxyTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCglibProxy() throws Exception {
|
void testCglibProxy() throws Exception {
|
||||||
ITest test = (ITest) Proxy.getProxy(ITest.class).newInstance((proxy, method, args) -> {
|
ITest test = (ITest) Proxy.getProxy(ITest.class).newInstance((proxy, method, args) -> {
|
||||||
System.out.println(method.getName());
|
System.out.println(method.getName());
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -74,4 +74,4 @@ public class ProxyTest {
|
||||||
return "Bye!";
|
return "Bye!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -26,9 +26,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
public class WrapperTest {
|
class WrapperTest {
|
||||||
@Test
|
@Test
|
||||||
public void testMain() throws Exception {
|
void testMain() throws Exception {
|
||||||
Wrapper w = Wrapper.getWrapper(I1.class);
|
Wrapper w = Wrapper.getWrapper(I1.class);
|
||||||
String[] ns = w.getDeclaredMethodNames();
|
String[] ns = w.getDeclaredMethodNames();
|
||||||
assertEquals(ns.length, 5);
|
assertEquals(ns.length, 5);
|
||||||
|
|
@ -52,7 +52,7 @@ public class WrapperTest {
|
||||||
|
|
||||||
// bug: DUBBO-132
|
// bug: DUBBO-132
|
||||||
@Test
|
@Test
|
||||||
public void test_unwantedArgument() throws Exception {
|
void test_unwantedArgument() throws Exception {
|
||||||
Wrapper w = Wrapper.getWrapper(I1.class);
|
Wrapper w = Wrapper.getWrapper(I1.class);
|
||||||
Object obj = new Impl1();
|
Object obj = new Impl1();
|
||||||
try {
|
try {
|
||||||
|
|
@ -65,12 +65,12 @@ public class WrapperTest {
|
||||||
|
|
||||||
//bug: DUBBO-425
|
//bug: DUBBO-425
|
||||||
@Test
|
@Test
|
||||||
public void test_makeEmptyClass() throws Exception {
|
void test_makeEmptyClass() throws Exception {
|
||||||
Wrapper.getWrapper(EmptyServiceImpl.class);
|
Wrapper.getWrapper(EmptyServiceImpl.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHasMethod() throws Exception {
|
void testHasMethod() throws Exception {
|
||||||
Wrapper w = Wrapper.getWrapper(I1.class);
|
Wrapper w = Wrapper.getWrapper(I1.class);
|
||||||
Assertions.assertTrue(w.hasMethod("setName"));
|
Assertions.assertTrue(w.hasMethod("setName"));
|
||||||
Assertions.assertTrue(w.hasMethod("hello"));
|
Assertions.assertTrue(w.hasMethod("hello"));
|
||||||
|
|
@ -81,7 +81,7 @@ public class WrapperTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWrapperObject() throws Exception {
|
void testWrapperObject() throws Exception {
|
||||||
Wrapper w = Wrapper.getWrapper(Object.class);
|
Wrapper w = Wrapper.getWrapper(Object.class);
|
||||||
Assertions.assertEquals(4, w.getMethodNames().length);
|
Assertions.assertEquals(4, w.getMethodNames().length);
|
||||||
Assertions.assertEquals(4, w.getDeclaredMethodNames().length);
|
Assertions.assertEquals(4, w.getDeclaredMethodNames().length);
|
||||||
|
|
@ -91,7 +91,7 @@ public class WrapperTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetPropertyValue() throws Exception {
|
void testGetPropertyValue() throws Exception {
|
||||||
Assertions.assertThrows(NoSuchPropertyException.class, () -> {
|
Assertions.assertThrows(NoSuchPropertyException.class, () -> {
|
||||||
Wrapper w = Wrapper.getWrapper(Object.class);
|
Wrapper w = Wrapper.getWrapper(Object.class);
|
||||||
w.getPropertyValue(null, null);
|
w.getPropertyValue(null, null);
|
||||||
|
|
@ -99,7 +99,7 @@ public class WrapperTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetPropertyValue() throws Exception {
|
void testSetPropertyValue() throws Exception {
|
||||||
Assertions.assertThrows(NoSuchPropertyException.class, () -> {
|
Assertions.assertThrows(NoSuchPropertyException.class, () -> {
|
||||||
Wrapper w = Wrapper.getWrapper(Object.class);
|
Wrapper w = Wrapper.getWrapper(Object.class);
|
||||||
w.setPropertyValue(null, null, null);
|
w.setPropertyValue(null, null, null);
|
||||||
|
|
@ -107,14 +107,14 @@ public class WrapperTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWrapPrimitive() throws Exception {
|
void testWrapPrimitive() throws Exception {
|
||||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||||
Wrapper.getWrapper(Byte.TYPE);
|
Wrapper.getWrapper(Byte.TYPE);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvokeWrapperObject() throws Exception {
|
void testInvokeWrapperObject() throws Exception {
|
||||||
Wrapper w = Wrapper.getWrapper(Object.class);
|
Wrapper w = Wrapper.getWrapper(Object.class);
|
||||||
Object instance = new Object();
|
Object instance = new Object();
|
||||||
Assertions.assertEquals(instance.getClass(), w.invokeMethod(instance, "getClass", null, null));
|
Assertions.assertEquals(instance.getClass(), w.invokeMethod(instance, "getClass", null, null));
|
||||||
|
|
@ -126,7 +126,7 @@ public class WrapperTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoSuchMethod() throws Exception {
|
void testNoSuchMethod() throws Exception {
|
||||||
Assertions.assertThrows(NoSuchMethodException.class, () -> {
|
Assertions.assertThrows(NoSuchMethodException.class, () -> {
|
||||||
Wrapper w = Wrapper.getWrapper(Object.class);
|
Wrapper w = Wrapper.getWrapper(Object.class);
|
||||||
w.invokeMethod(new Object(), "__XX__", null, null);
|
w.invokeMethod(new Object(), "__XX__", null, null);
|
||||||
|
|
@ -134,7 +134,7 @@ public class WrapperTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOverloadMethod() throws Exception {
|
void testOverloadMethod() throws Exception {
|
||||||
Wrapper w = Wrapper.getWrapper(I2.class);
|
Wrapper w = Wrapper.getWrapper(I2.class);
|
||||||
assertEquals(2, w.getMethodNames().length);
|
assertEquals(2, w.getMethodNames().length);
|
||||||
|
|
||||||
|
|
@ -154,7 +154,7 @@ public class WrapperTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_getDeclaredMethodNames_ContainExtendsParentMethods() throws Exception {
|
void test_getDeclaredMethodNames_ContainExtendsParentMethods() throws Exception {
|
||||||
assertArrayEquals(new String[]{"hello",}, Wrapper.getWrapper(Parent1.class).getMethodNames());
|
assertArrayEquals(new String[]{"hello",}, Wrapper.getWrapper(Parent1.class).getMethodNames());
|
||||||
assertArrayEquals(new String[]{"hello",}, ClassUtils.getMethodNames(Parent1.class));
|
assertArrayEquals(new String[]{"hello",}, ClassUtils.getMethodNames(Parent1.class));
|
||||||
|
|
||||||
|
|
@ -163,13 +163,13 @@ public class WrapperTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_getMethodNames_ContainExtendsParentMethods() throws Exception {
|
void test_getMethodNames_ContainExtendsParentMethods() throws Exception {
|
||||||
assertArrayEquals(new String[]{"hello", "world"}, Wrapper.getWrapper(Son.class).getMethodNames());
|
assertArrayEquals(new String[]{"hello", "world"}, Wrapper.getWrapper(Son.class).getMethodNames());
|
||||||
assertArrayEquals(new String[]{"hello", "world"}, ClassUtils.getMethodNames(Son.class));
|
assertArrayEquals(new String[]{"hello", "world"}, ClassUtils.getMethodNames(Son.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWrapImplClass(){
|
void testWrapImplClass(){
|
||||||
Wrapper w = Wrapper.getWrapper(Impl0.class);
|
Wrapper w = Wrapper.getWrapper(Impl0.class);
|
||||||
|
|
||||||
String[] propertyNames = w.getPropertyNames();
|
String[] propertyNames = w.getPropertyNames();
|
||||||
|
|
@ -293,4 +293,4 @@ public class WrapperTest {
|
||||||
|
|
||||||
public static class EmptyServiceImpl implements EmptyService {
|
public static class EmptyServiceImpl implements EmptyService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -71,4 +71,4 @@ class FileCacheStoreFactoryTest {
|
||||||
String directoryPath = path.substring(0, index);
|
String directoryPath = path.substring(0, index);
|
||||||
return directoryPath;
|
return directoryPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -75,4 +75,4 @@ class FileCacheStoreTest {
|
||||||
return directoryPath;
|
return directoryPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -21,10 +21,10 @@ import org.apache.dubbo.rpc.model.FrameworkModel;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class AdaptiveCompilerTest extends JavaCodeTest {
|
class AdaptiveCompilerTest extends JavaCodeTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAvailableCompiler() throws Exception {
|
void testAvailableCompiler() throws Exception {
|
||||||
AdaptiveCompiler.setDefaultCompiler("jdk");
|
AdaptiveCompiler.setDefaultCompiler("jdk");
|
||||||
AdaptiveCompiler compiler = new AdaptiveCompiler();
|
AdaptiveCompiler compiler = new AdaptiveCompiler();
|
||||||
compiler.setFrameworkModel(FrameworkModel.defaultModel());
|
compiler.setFrameworkModel(FrameworkModel.defaultModel());
|
||||||
|
|
@ -33,4 +33,4 @@ public class AdaptiveCompilerTest extends JavaCodeTest {
|
||||||
Assertions.assertEquals("Hello world!", helloService.sayHello());
|
Assertions.assertEquals("Hello world!", helloService.sayHello());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -25,41 +25,41 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class ClassUtilsTest {
|
class ClassUtilsTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNewInstance() {
|
void testNewInstance() {
|
||||||
HelloServiceImpl0 instance = (HelloServiceImpl0) ClassUtils.newInstance(HelloServiceImpl0.class.getName());
|
HelloServiceImpl0 instance = (HelloServiceImpl0) ClassUtils.newInstance(HelloServiceImpl0.class.getName());
|
||||||
Assertions.assertEquals("Hello world!", instance.sayHello());
|
Assertions.assertEquals("Hello world!", instance.sayHello());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNewInstance0() {
|
void testNewInstance0() {
|
||||||
Assertions.assertThrows(IllegalStateException.class, () -> ClassUtils.newInstance(PrivateHelloServiceImpl.class.getName()));
|
Assertions.assertThrows(IllegalStateException.class, () -> ClassUtils.newInstance(PrivateHelloServiceImpl.class.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNewInstance1() {
|
void testNewInstance1() {
|
||||||
Assertions.assertThrows(IllegalStateException.class, () -> ClassUtils.newInstance("org.apache.dubbo.common.compiler.support.internal.HelloServiceInternalImpl"));
|
Assertions.assertThrows(IllegalStateException.class, () -> ClassUtils.newInstance("org.apache.dubbo.common.compiler.support.internal.HelloServiceInternalImpl"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNewInstance2() {
|
void testNewInstance2() {
|
||||||
Assertions.assertThrows(IllegalStateException.class, () -> ClassUtils.newInstance("org.apache.dubbo.common.compiler.support.internal.NotExistsImpl"));
|
Assertions.assertThrows(IllegalStateException.class, () -> ClassUtils.newInstance("org.apache.dubbo.common.compiler.support.internal.NotExistsImpl"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testForName() {
|
void testForName() {
|
||||||
ClassUtils.forName(new String[]{"org.apache.dubbo.common.compiler.support"}, "HelloServiceImpl0");
|
ClassUtils.forName(new String[]{"org.apache.dubbo.common.compiler.support"}, "HelloServiceImpl0");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testForName1() {
|
void testForName1() {
|
||||||
Assertions.assertThrows(IllegalStateException.class, () -> ClassUtils.forName(new String[]{"org.apache.dubbo.common.compiler.support"}, "HelloServiceImplXX"));
|
Assertions.assertThrows(IllegalStateException.class, () -> ClassUtils.forName(new String[]{"org.apache.dubbo.common.compiler.support"}, "HelloServiceImplXX"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testForName2() {
|
void testForName2() {
|
||||||
ClassUtils.forName("boolean");
|
ClassUtils.forName("boolean");
|
||||||
ClassUtils.forName("byte");
|
ClassUtils.forName("byte");
|
||||||
ClassUtils.forName("char");
|
ClassUtils.forName("char");
|
||||||
|
|
@ -79,7 +79,7 @@ public class ClassUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetBoxedClass() {
|
void testGetBoxedClass() {
|
||||||
Assertions.assertEquals(Boolean.class, ClassUtils.getBoxedClass(boolean.class));
|
Assertions.assertEquals(Boolean.class, ClassUtils.getBoxedClass(boolean.class));
|
||||||
Assertions.assertEquals(Character.class, ClassUtils.getBoxedClass(char.class));
|
Assertions.assertEquals(Character.class, ClassUtils.getBoxedClass(char.class));
|
||||||
Assertions.assertEquals(Byte.class, ClassUtils.getBoxedClass(byte.class));
|
Assertions.assertEquals(Byte.class, ClassUtils.getBoxedClass(byte.class));
|
||||||
|
|
@ -92,7 +92,7 @@ public class ClassUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBoxedAndUnboxed() {
|
void testBoxedAndUnboxed() {
|
||||||
Assertions.assertEquals(Boolean.valueOf(true), ClassUtils.boxed(true));
|
Assertions.assertEquals(Boolean.valueOf(true), ClassUtils.boxed(true));
|
||||||
Assertions.assertEquals(Character.valueOf('0'), ClassUtils.boxed('0'));
|
Assertions.assertEquals(Character.valueOf('0'), ClassUtils.boxed('0'));
|
||||||
Assertions.assertEquals(Byte.valueOf((byte) 0), ClassUtils.boxed((byte) 0));
|
Assertions.assertEquals(Byte.valueOf((byte) 0), ClassUtils.boxed((byte) 0));
|
||||||
|
|
@ -113,7 +113,7 @@ public class ClassUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetSize() {
|
void testGetSize() {
|
||||||
Assertions.assertEquals(0, ClassUtils.getSize(null));
|
Assertions.assertEquals(0, ClassUtils.getSize(null));
|
||||||
List<Integer> list = new ArrayList<>();
|
List<Integer> list = new ArrayList<>();
|
||||||
list.add(1);
|
list.add(1);
|
||||||
|
|
@ -127,17 +127,17 @@ public class ClassUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testToUri() {
|
void testToUri() {
|
||||||
Assertions.assertThrows(RuntimeException.class, () -> ClassUtils.toURI("#xx_abc#hello"));
|
Assertions.assertThrows(RuntimeException.class, () -> ClassUtils.toURI("#xx_abc#hello"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetSizeMethod() {
|
void testGetSizeMethod() {
|
||||||
Assertions.assertEquals("getLength()", ClassUtils.getSizeMethod(GenericClass3.class));
|
Assertions.assertEquals("getLength()", ClassUtils.getSizeMethod(GenericClass3.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetSimpleClassName() {
|
void testGetSimpleClassName() {
|
||||||
Assertions.assertNull(ClassUtils.getSimpleClassName(null));
|
Assertions.assertNull(ClassUtils.getSimpleClassName(null));
|
||||||
Assertions.assertEquals("Map", ClassUtils.getSimpleClassName(Map.class.getName()));
|
Assertions.assertEquals("Map", ClassUtils.getSimpleClassName(Map.class.getName()));
|
||||||
Assertions.assertEquals("Map", ClassUtils.getSimpleClassName(Map.class.getSimpleName()));
|
Assertions.assertEquals("Map", ClassUtils.getSimpleClassName(Map.class.getSimpleName()));
|
||||||
|
|
@ -174,4 +174,4 @@ public class ClassUtilsTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -18,7 +18,7 @@ package org.apache.dubbo.common.compiler.support;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public class JavaCodeTest {
|
class JavaCodeTest {
|
||||||
|
|
||||||
public final static AtomicInteger SUBFIX = new AtomicInteger(8);
|
public final static AtomicInteger SUBFIX = new AtomicInteger(8);
|
||||||
|
|
||||||
|
|
@ -107,4 +107,4 @@ public class JavaCodeTest {
|
||||||
code.append('}');
|
code.append('}');
|
||||||
return code.toString();
|
return code.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -23,9 +23,9 @@ import org.junit.jupiter.api.condition.JRE;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
public class JavassistCompilerTest extends JavaCodeTest {
|
class JavassistCompilerTest extends JavaCodeTest {
|
||||||
@Test
|
@Test
|
||||||
public void testCompileJavaClass() throws Exception {
|
void testCompileJavaClass() throws Exception {
|
||||||
JavassistCompiler compiler = new JavassistCompiler();
|
JavassistCompiler compiler = new JavassistCompiler();
|
||||||
Class<?> clazz = compiler.compile(JavaCodeTest.class, getSimpleCode(), JavassistCompiler.class.getClassLoader());
|
Class<?> clazz = compiler.compile(JavaCodeTest.class, getSimpleCode(), JavassistCompiler.class.getClassLoader());
|
||||||
|
|
||||||
|
|
@ -55,7 +55,7 @@ public class JavassistCompilerTest extends JavaCodeTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCompileJavaClass1() throws Exception {
|
void testCompileJavaClass1() throws Exception {
|
||||||
Assertions.assertThrows(IllegalStateException.class, () -> {
|
Assertions.assertThrows(IllegalStateException.class, () -> {
|
||||||
JavassistCompiler compiler = new JavassistCompiler();
|
JavassistCompiler compiler = new JavassistCompiler();
|
||||||
Class<?> clazz = compiler.compile(JavaCodeTest.class, getSimpleCodeWithSyntax0(), JavassistCompiler.class.getClassLoader());
|
Class<?> clazz = compiler.compile(JavaCodeTest.class, getSimpleCodeWithSyntax0(), JavassistCompiler.class.getClassLoader());
|
||||||
|
|
@ -66,7 +66,7 @@ public class JavassistCompilerTest extends JavaCodeTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCompileJavaClassWithImport() throws Exception {
|
void testCompileJavaClassWithImport() throws Exception {
|
||||||
JavassistCompiler compiler = new JavassistCompiler();
|
JavassistCompiler compiler = new JavassistCompiler();
|
||||||
Class<?> clazz = compiler.compile(JavaCodeTest.class, getSimpleCodeWithImports(), JavassistCompiler.class.getClassLoader());
|
Class<?> clazz = compiler.compile(JavaCodeTest.class, getSimpleCodeWithImports(), JavassistCompiler.class.getClassLoader());
|
||||||
Object instance = clazz.newInstance();
|
Object instance = clazz.newInstance();
|
||||||
|
|
@ -75,11 +75,11 @@ public class JavassistCompilerTest extends JavaCodeTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCompileJavaClassWithExtends() throws Exception {
|
void testCompileJavaClassWithExtends() throws Exception {
|
||||||
JavassistCompiler compiler = new JavassistCompiler();
|
JavassistCompiler compiler = new JavassistCompiler();
|
||||||
Class<?> clazz = compiler.compile(JavaCodeTest.class, getSimpleCodeWithWithExtends(), JavassistCompiler.class.getClassLoader());
|
Class<?> clazz = compiler.compile(JavaCodeTest.class, getSimpleCodeWithWithExtends(), JavassistCompiler.class.getClassLoader());
|
||||||
Object instance = clazz.newInstance();
|
Object instance = clazz.newInstance();
|
||||||
Method sayHello = instance.getClass().getMethod("sayHello");
|
Method sayHello = instance.getClass().getMethod("sayHello");
|
||||||
Assertions.assertEquals("Hello world3!", sayHello.invoke(instance));
|
Assertions.assertEquals("Hello world3!", sayHello.invoke(instance));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -21,10 +21,10 @@ import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
public class JdkCompilerTest extends JavaCodeTest {
|
class JdkCompilerTest extends JavaCodeTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_compileJavaClass() throws Exception {
|
void test_compileJavaClass() throws Exception {
|
||||||
JdkCompiler compiler = new JdkCompiler();
|
JdkCompiler compiler = new JdkCompiler();
|
||||||
Class<?> clazz = compiler.compile(JavaCodeTest.class, getSimpleCode(), JdkCompiler.class.getClassLoader());
|
Class<?> clazz = compiler.compile(JavaCodeTest.class, getSimpleCode(), JdkCompiler.class.getClassLoader());
|
||||||
Object instance = clazz.newInstance();
|
Object instance = clazz.newInstance();
|
||||||
|
|
@ -33,7 +33,7 @@ public class JdkCompilerTest extends JavaCodeTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_compileJavaClass0() throws Exception {
|
void test_compileJavaClass0() throws Exception {
|
||||||
Assertions.assertThrows(IllegalStateException.class, () -> {
|
Assertions.assertThrows(IllegalStateException.class, () -> {
|
||||||
JdkCompiler compiler = new JdkCompiler();
|
JdkCompiler compiler = new JdkCompiler();
|
||||||
Class<?> clazz = compiler.compile(JavaCodeTest.class, getSimpleCodeWithoutPackage(), JdkCompiler.class.getClassLoader());
|
Class<?> clazz = compiler.compile(JavaCodeTest.class, getSimpleCodeWithoutPackage(), JdkCompiler.class.getClassLoader());
|
||||||
|
|
@ -44,7 +44,7 @@ public class JdkCompilerTest extends JavaCodeTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_compileJavaClass1() throws Exception {
|
void test_compileJavaClass1() throws Exception {
|
||||||
Assertions.assertThrows(IllegalStateException.class, () -> {
|
Assertions.assertThrows(IllegalStateException.class, () -> {
|
||||||
JdkCompiler compiler = new JdkCompiler();
|
JdkCompiler compiler = new JdkCompiler();
|
||||||
Class<?> clazz = compiler.compile(JavaCodeTest.class, getSimpleCodeWithSyntax(), JdkCompiler.class.getClassLoader());
|
Class<?> clazz = compiler.compile(JavaCodeTest.class, getSimpleCodeWithSyntax(), JdkCompiler.class.getClassLoader());
|
||||||
|
|
@ -55,7 +55,7 @@ public class JdkCompilerTest extends JavaCodeTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_compileJavaClass_java8() throws Exception {
|
void test_compileJavaClass_java8() throws Exception {
|
||||||
JdkCompiler compiler = new JdkCompiler("1.8");
|
JdkCompiler compiler = new JdkCompiler("1.8");
|
||||||
Class<?> clazz = compiler.compile(JavaCodeTest.class, getSimpleCode(), JdkCompiler.class.getClassLoader());
|
Class<?> clazz = compiler.compile(JavaCodeTest.class, getSimpleCode(), JdkCompiler.class.getClassLoader());
|
||||||
Object instance = clazz.newInstance();
|
Object instance = clazz.newInstance();
|
||||||
|
|
@ -64,7 +64,7 @@ public class JdkCompilerTest extends JavaCodeTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_compileJavaClass0_java8() throws Exception {
|
void test_compileJavaClass0_java8() throws Exception {
|
||||||
Assertions.assertThrows(IllegalStateException.class, () -> {
|
Assertions.assertThrows(IllegalStateException.class, () -> {
|
||||||
JdkCompiler compiler = new JdkCompiler("1.8");
|
JdkCompiler compiler = new JdkCompiler("1.8");
|
||||||
Class<?> clazz = compiler.compile(JavaCodeTest.class, getSimpleCodeWithoutPackage(), JdkCompiler.class.getClassLoader());
|
Class<?> clazz = compiler.compile(JavaCodeTest.class, getSimpleCodeWithoutPackage(), JdkCompiler.class.getClassLoader());
|
||||||
|
|
@ -75,7 +75,7 @@ public class JdkCompilerTest extends JavaCodeTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_compileJavaClass1_java8() throws Exception {
|
void test_compileJavaClass1_java8() throws Exception {
|
||||||
Assertions.assertThrows(IllegalStateException.class, () -> {
|
Assertions.assertThrows(IllegalStateException.class, () -> {
|
||||||
JdkCompiler compiler = new JdkCompiler("1.8");
|
JdkCompiler compiler = new JdkCompiler("1.8");
|
||||||
Class<?> clazz = compiler.compile(JavaCodeTest.class, getSimpleCodeWithSyntax(), JdkCompiler.class.getClassLoader());
|
Class<?> clazz = compiler.compile(JavaCodeTest.class, getSimpleCodeWithSyntax(), JdkCompiler.class.getClassLoader());
|
||||||
|
|
@ -84,4 +84,4 @@ public class JdkCompilerTest extends JavaCodeTest {
|
||||||
Assertions.assertEquals("Hello world!", sayHello.invoke(instance));
|
Assertions.assertEquals("Hello world!", sayHello.invoke(instance));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -37,12 +37,12 @@ import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
|
|
||||||
public class CompletableFutureTaskTest {
|
class CompletableFutureTaskTest {
|
||||||
|
|
||||||
private static final ExecutorService executor = new ThreadPoolExecutor(0, 10, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), new NamedThreadFactory("DubboMonitorCreator", true));
|
private static final ExecutorService executor = new ThreadPoolExecutor(0, 10, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), new NamedThreadFactory("DubboMonitorCreator", true));
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreate() throws InterruptedException {
|
void testCreate() throws InterruptedException {
|
||||||
|
|
||||||
final CountDownLatch countDownLatch = new CountDownLatch(1);
|
final CountDownLatch countDownLatch = new CountDownLatch(1);
|
||||||
CompletableFuture<Boolean> completableFuture = CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<Boolean> completableFuture = CompletableFuture.supplyAsync(() -> {
|
||||||
|
|
@ -53,7 +53,7 @@ public class CompletableFutureTaskTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRunnableResponse() throws ExecutionException, InterruptedException {
|
void testRunnableResponse() throws ExecutionException, InterruptedException {
|
||||||
CompletableFuture<Boolean> completableFuture = CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<Boolean> completableFuture = CompletableFuture.supplyAsync(() -> {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
|
|
@ -68,7 +68,7 @@ public class CompletableFutureTaskTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListener() throws InterruptedException {
|
void testListener() throws InterruptedException {
|
||||||
CompletableFuture<String> completableFuture = CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<String> completableFuture = CompletableFuture.supplyAsync(() -> {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
|
|
@ -84,8 +84,8 @@ public class CompletableFutureTaskTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCustomExecutor() {
|
void testCustomExecutor() {
|
||||||
Executor mockedExecutor = mock(Executor.class);
|
Executor mockedExecutor = mock(Executor.class);
|
||||||
CompletableFuture<Integer> completableFuture = CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<Integer> completableFuture = CompletableFuture.supplyAsync(() -> {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -93,4 +93,4 @@ public class CompletableFutureTaskTest {
|
||||||
completableFuture.thenRunAsync(mock(Runnable.class), mockedExecutor).whenComplete((s, e) ->
|
completableFuture.thenRunAsync(mock(Runnable.class), mockedExecutor).whenComplete((s, e) ->
|
||||||
verify(mockedExecutor, times(1)).execute(any(Runnable.class)));
|
verify(mockedExecutor, times(1)).execute(any(Runnable.class)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -22,10 +22,10 @@ import org.junit.jupiter.api.Test;
|
||||||
/**
|
/**
|
||||||
* {@link CompositeConfiguration}
|
* {@link CompositeConfiguration}
|
||||||
*/
|
*/
|
||||||
public class CompositeConfigurationTest {
|
class CompositeConfigurationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
void test() {
|
||||||
InmemoryConfiguration inmemoryConfiguration1 = new InmemoryConfiguration();
|
InmemoryConfiguration inmemoryConfiguration1 = new InmemoryConfiguration();
|
||||||
InmemoryConfiguration inmemoryConfiguration2 = new InmemoryConfiguration();
|
InmemoryConfiguration inmemoryConfiguration2 = new InmemoryConfiguration();
|
||||||
InmemoryConfiguration inmemoryConfiguration3 = new InmemoryConfiguration();
|
InmemoryConfiguration inmemoryConfiguration3 = new InmemoryConfiguration();
|
||||||
|
|
@ -39,4 +39,4 @@ public class CompositeConfigurationTest {
|
||||||
|
|
||||||
Assertions.assertEquals(configuration.getInternalProperty("k"), "v3");
|
Assertions.assertEquals(configuration.getInternalProperty("k"), "v3");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -22,14 +22,14 @@ import org.junit.jupiter.api.Test;
|
||||||
/**
|
/**
|
||||||
* {@link ConfigurationCache}
|
* {@link ConfigurationCache}
|
||||||
*/
|
*/
|
||||||
public class ConfigurationCacheTest {
|
class ConfigurationCacheTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
void test() {
|
||||||
ConfigurationCache configurationCache = new ConfigurationCache();
|
ConfigurationCache configurationCache = new ConfigurationCache();
|
||||||
String value = configurationCache.computeIfAbsent("k1", k -> "v1");
|
String value = configurationCache.computeIfAbsent("k1", k -> "v1");
|
||||||
Assertions.assertEquals(value, "v1");
|
Assertions.assertEquals(value, "v1");
|
||||||
value = configurationCache.computeIfAbsent("k1", k -> "v2");
|
value = configurationCache.computeIfAbsent("k1", k -> "v2");
|
||||||
Assertions.assertEquals(value, "v1");
|
Assertions.assertEquals(value, "v1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -31,9 +31,9 @@ import static org.apache.dubbo.common.constants.CommonConstants.SHUTDOWN_WAIT_KE
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ConfigurationUtilsTest {
|
class ConfigurationUtilsTest {
|
||||||
@Test
|
@Test
|
||||||
public void testCachedProperties() {
|
void testCachedProperties() {
|
||||||
FrameworkModel frameworkModel = new FrameworkModel();
|
FrameworkModel frameworkModel = new FrameworkModel();
|
||||||
|
|
||||||
ApplicationModel applicationModel = new ApplicationModel(frameworkModel);
|
ApplicationModel applicationModel = new ApplicationModel(frameworkModel);
|
||||||
|
|
@ -72,21 +72,21 @@ public class ConfigurationUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetServerShutdownTimeout () {
|
void testGetServerShutdownTimeout () {
|
||||||
System.setProperty(SHUTDOWN_WAIT_KEY, " 10000");
|
System.setProperty(SHUTDOWN_WAIT_KEY, " 10000");
|
||||||
Assertions.assertEquals(10000, ConfigurationUtils.getServerShutdownTimeout(ApplicationModel.defaultModel()));
|
Assertions.assertEquals(10000, ConfigurationUtils.getServerShutdownTimeout(ApplicationModel.defaultModel()));
|
||||||
System.clearProperty(SHUTDOWN_WAIT_KEY);
|
System.clearProperty(SHUTDOWN_WAIT_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetProperty () {
|
void testGetProperty () {
|
||||||
System.setProperty(SHUTDOWN_WAIT_KEY, " 10000");
|
System.setProperty(SHUTDOWN_WAIT_KEY, " 10000");
|
||||||
Assertions.assertEquals("10000", ConfigurationUtils.getProperty(ApplicationModel.defaultModel(), SHUTDOWN_WAIT_KEY));
|
Assertions.assertEquals("10000", ConfigurationUtils.getProperty(ApplicationModel.defaultModel(), SHUTDOWN_WAIT_KEY));
|
||||||
System.clearProperty(SHUTDOWN_WAIT_KEY);
|
System.clearProperty(SHUTDOWN_WAIT_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParseSingleProperties() throws Exception {
|
void testParseSingleProperties() throws Exception {
|
||||||
String p1 = "aaa=bbb";
|
String p1 = "aaa=bbb";
|
||||||
Map<String, String> result = ConfigurationUtils.parseProperties(p1);
|
Map<String, String> result = ConfigurationUtils.parseProperties(p1);
|
||||||
Assertions.assertEquals(1, result.size());
|
Assertions.assertEquals(1, result.size());
|
||||||
|
|
@ -94,7 +94,7 @@ public class ConfigurationUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParseMultipleProperties() throws Exception {
|
void testParseMultipleProperties() throws Exception {
|
||||||
String p1 = "aaa=bbb\nccc=ddd";
|
String p1 = "aaa=bbb\nccc=ddd";
|
||||||
Map<String, String> result = ConfigurationUtils.parseProperties(p1);
|
Map<String, String> result = ConfigurationUtils.parseProperties(p1);
|
||||||
Assertions.assertEquals(2, result.size());
|
Assertions.assertEquals(2, result.size());
|
||||||
|
|
@ -103,10 +103,10 @@ public class ConfigurationUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEscapedNewLine() throws Exception {
|
void testEscapedNewLine() throws Exception {
|
||||||
String p1 = "dubbo.registry.address=zookeeper://127.0.0.1:2181\\\\ndubbo.protocol.port=20880";
|
String p1 = "dubbo.registry.address=zookeeper://127.0.0.1:2181\\\\ndubbo.protocol.port=20880";
|
||||||
Map<String, String> result = ConfigurationUtils.parseProperties(p1);
|
Map<String, String> result = ConfigurationUtils.parseProperties(p1);
|
||||||
Assertions.assertEquals(1, result.size());
|
Assertions.assertEquals(1, result.size());
|
||||||
Assertions.assertEquals("zookeeper://127.0.0.1:2181\\ndubbo.protocol.port=20880", result.get("dubbo.registry.address"));
|
Assertions.assertEquals("zookeeper://127.0.0.1:2181\\ndubbo.protocol.port=20880", result.get("dubbo.registry.address"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -29,7 +29,7 @@ import java.util.Map;
|
||||||
/**
|
/**
|
||||||
* The type Environment configuration test.
|
* The type Environment configuration test.
|
||||||
*/
|
*/
|
||||||
public class EnvironmentConfigurationTest {
|
class EnvironmentConfigurationTest {
|
||||||
|
|
||||||
private static final String MOCK_KEY = "DUBBO_KEY";
|
private static final String MOCK_KEY = "DUBBO_KEY";
|
||||||
private static final String MOCK_VALUE = "mockValue";
|
private static final String MOCK_VALUE = "mockValue";
|
||||||
|
|
@ -43,7 +43,7 @@ public class EnvironmentConfigurationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetInternalProperty() {
|
void testGetInternalProperty() {
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
map.put(MOCK_KEY, MOCK_VALUE);
|
map.put(MOCK_KEY, MOCK_VALUE);
|
||||||
try {
|
try {
|
||||||
|
|
@ -101,4 +101,4 @@ public class EnvironmentConfigurationTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -35,10 +35,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
/**
|
/**
|
||||||
* {@link Environment}
|
* {@link Environment}
|
||||||
*/
|
*/
|
||||||
public class EnvironmentTest {
|
class EnvironmentTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testResolvePlaceholders() {
|
void testResolvePlaceholders() {
|
||||||
Environment environment = ApplicationModel.defaultModel().getModelEnvironment();
|
Environment environment = ApplicationModel.defaultModel().getModelEnvironment();
|
||||||
|
|
||||||
Map<String, String> externalMap = new LinkedHashMap<>();
|
Map<String, String> externalMap = new LinkedHashMap<>();
|
||||||
|
|
@ -62,7 +62,7 @@ public class EnvironmentTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
void test() {
|
||||||
FrameworkModel frameworkModel = new FrameworkModel();
|
FrameworkModel frameworkModel = new FrameworkModel();
|
||||||
ApplicationModel applicationModel = new ApplicationModel(frameworkModel);
|
ApplicationModel applicationModel = new ApplicationModel(frameworkModel);
|
||||||
Environment environment = applicationModel.getModelEnvironment();
|
Environment environment = applicationModel.getModelEnvironment();
|
||||||
|
|
@ -112,4 +112,4 @@ public class EnvironmentTest {
|
||||||
|
|
||||||
frameworkModel.destroy();
|
frameworkModel.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -159,4 +159,4 @@ class InmemoryConfigurationTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -25,12 +25,12 @@ import org.junit.jupiter.api.Test;
|
||||||
/**
|
/**
|
||||||
* {@link OrderedPropertiesConfiguration}
|
* {@link OrderedPropertiesConfiguration}
|
||||||
*/
|
*/
|
||||||
public class OrderedPropertiesConfigurationTest {
|
class OrderedPropertiesConfigurationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOrderPropertiesProviders() {
|
void testOrderPropertiesProviders() {
|
||||||
OrderedPropertiesConfiguration configuration = new OrderedPropertiesConfiguration(ApplicationModel.defaultModel().getDefaultModule());
|
OrderedPropertiesConfiguration configuration = new OrderedPropertiesConfiguration(ApplicationModel.defaultModel().getDefaultModule());
|
||||||
Assertions.assertEquals("999", configuration.getInternalProperty("testKey"));
|
Assertions.assertEquals("999", configuration.getInternalProperty("testKey"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -22,10 +22,10 @@ import org.junit.jupiter.api.Test;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class PrefixedConfigurationTest {
|
class PrefixedConfigurationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPrefixedConfiguration() {
|
void testPrefixedConfiguration() {
|
||||||
Map<String,String> props = new LinkedHashMap<>();
|
Map<String,String> props = new LinkedHashMap<>();
|
||||||
props.put("dubbo.protocol.name", "dubbo");
|
props.put("dubbo.protocol.name", "dubbo");
|
||||||
props.put("dubbo.protocol.port", "1234");
|
props.put("dubbo.protocol.port", "1234");
|
||||||
|
|
@ -48,4 +48,4 @@ public class PrefixedConfigurationTest {
|
||||||
Assertions.assertEquals("2345", prefixedConfiguration.getProperty("port"));
|
Assertions.assertEquals("2345", prefixedConfiguration.getProperty("port"));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue