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