mirror of
https://github.com/apache/dubbo.git
synced 2024-10-23 07:04:37 +08:00
Remove public modifier in configcenter, container, filter, kubernetes… (#10979)
This commit is contained in:
parent
b8664c4235
commit
45120670ba
@ -41,7 +41,7 @@ import static org.junit.jupiter.api.Assertions.fail;
|
||||
* Notice: EmbeddedApollo(apollo mock server) only support < junit5, please not upgrade the junit version in this UT,
|
||||
* the junit version in this UT is junit4, and the dependency comes from apollo-mockserver.
|
||||
*/
|
||||
public class ApolloDynamicConfigurationTest {
|
||||
class ApolloDynamicConfigurationTest {
|
||||
private static final String SESSION_TIMEOUT_KEY = "session";
|
||||
private static final String DEFAULT_NAMESPACE = "dubbo";
|
||||
private static ApolloDynamicConfiguration apolloDynamicConfiguration;
|
||||
@ -84,7 +84,7 @@ public class ApolloDynamicConfigurationTest {
|
||||
* Test get rule.
|
||||
*/
|
||||
@Test
|
||||
public void testGetRule() {
|
||||
void testGetRule() {
|
||||
String mockKey = "mockKey1";
|
||||
String mockValue = String.valueOf(new Random().nextInt());
|
||||
putMockRuleData(mockKey, mockValue, DEFAULT_NAMESPACE);
|
||||
@ -101,7 +101,7 @@ public class ApolloDynamicConfigurationTest {
|
||||
* @throws InterruptedException the interrupted exception
|
||||
*/
|
||||
@Test
|
||||
public void testGetInternalProperty() throws InterruptedException {
|
||||
void testGetInternalProperty() throws InterruptedException {
|
||||
String mockKey = "mockKey2";
|
||||
String mockValue = String.valueOf(new Random().nextInt());
|
||||
putMockRuleData(mockKey, mockValue, DEFAULT_NAMESPACE);
|
||||
@ -123,7 +123,7 @@ public class ApolloDynamicConfigurationTest {
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void testAddListener() throws Exception {
|
||||
void testAddListener() throws Exception {
|
||||
String mockKey = "mockKey3";
|
||||
String mockValue = String.valueOf(new Random().nextInt());
|
||||
|
||||
@ -187,4 +187,4 @@ public class ApolloDynamicConfigurationTest {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -44,7 +44,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
*/
|
||||
//FIXME: waiting for embedded Nacos suport, then we can open the switch.
|
||||
@Disabled("https://github.com/alibaba/nacos/issues/1188")
|
||||
public class NacosDynamicConfigurationTest {
|
||||
class NacosDynamicConfigurationTest {
|
||||
private static final String SESSION_TIMEOUT_KEY = "session";
|
||||
|
||||
private static NacosDynamicConfiguration config;
|
||||
@ -55,7 +55,7 @@ public class NacosDynamicConfigurationTest {
|
||||
private static ConfigService nacosClient;
|
||||
|
||||
@Test
|
||||
public void testGetConfig() throws Exception {
|
||||
void testGetConfig() throws Exception {
|
||||
put("org.apache.dubbo.nacos.testService.configurators", "hello");
|
||||
Thread.sleep(200);
|
||||
put("dubbo.properties", "test", "aaa=bbb");
|
||||
@ -68,7 +68,7 @@ public class NacosDynamicConfigurationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddListener() throws Exception {
|
||||
void testAddListener() throws Exception {
|
||||
CountDownLatch latch = new CountDownLatch(4);
|
||||
TestListener listener1 = new TestListener(latch);
|
||||
TestListener listener2 = new TestListener(latch);
|
||||
@ -143,7 +143,7 @@ public class NacosDynamicConfigurationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPublishConfig() {
|
||||
void testPublishConfig() {
|
||||
String key = "user-service";
|
||||
String group = "org.apache.dubbo.service.UserService";
|
||||
String content = "test";
|
||||
@ -184,4 +184,4 @@ public class NacosDynamicConfigurationTest {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -45,7 +45,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
* TODO refactor using mockito
|
||||
*/
|
||||
@Disabled("Disabled Due to Zookeeper in Github Actions")
|
||||
public class ZookeeperDynamicConfigurationTest {
|
||||
class ZookeeperDynamicConfigurationTest {
|
||||
private static CuratorFramework client;
|
||||
|
||||
private static URL configUrl;
|
||||
@ -98,12 +98,12 @@ public class ZookeeperDynamicConfigurationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetConfig() {
|
||||
void testGetConfig() {
|
||||
Assertions.assertEquals("The content from dubbo.properties", configuration.getConfig("dubbo.properties", "dubbo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddListener() throws Exception {
|
||||
void testAddListener() throws Exception {
|
||||
CountDownLatch latch = new CountDownLatch(4);
|
||||
|
||||
String[] value1 = new String[1], value2 = new String[1], value3 = new String[1], value4 = new String[1];
|
||||
@ -141,7 +141,7 @@ public class ZookeeperDynamicConfigurationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPublishConfig() {
|
||||
void testPublishConfig() {
|
||||
String key = "user-service";
|
||||
String group = "org.apache.dubbo.service.UserService";
|
||||
String content = "test";
|
||||
@ -151,7 +151,7 @@ public class ZookeeperDynamicConfigurationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPublishConfigCas() {
|
||||
void testPublishConfigCas() {
|
||||
String key = "user-service-cas";
|
||||
String group = "org.apache.dubbo.service.UserService";
|
||||
String content = "test";
|
||||
@ -181,4 +181,4 @@ public class ZookeeperDynamicConfigurationTest {
|
||||
// assertEquals(new TreeSet(asList(key, key2)), configKeys);
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
@ -25,14 +25,14 @@ import org.junit.jupiter.api.Test;
|
||||
/**
|
||||
* StandaloneContainerTest
|
||||
*/
|
||||
public class SpringContainerTest {
|
||||
class SpringContainerTest {
|
||||
|
||||
@Test
|
||||
public void testContainer() {
|
||||
void testContainer() {
|
||||
SpringContainer container = (SpringContainer) ExtensionLoader.getExtensionLoader(Container.class).getExtension("spring");
|
||||
container.start();
|
||||
Assertions.assertEquals(SpringContainer.class, container.context.getBean("container").getClass());
|
||||
container.stop();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -37,7 +37,7 @@ import java.util.stream.Stream;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
public class CacheFilterTest {
|
||||
class CacheFilterTest {
|
||||
private RpcInvocation invocation;
|
||||
private CacheFilter cacheFilter = new CacheFilter();
|
||||
private Invoker<?> invoker = mock(Invoker.class);
|
||||
@ -138,4 +138,4 @@ public class CacheFilterTest {
|
||||
Assertions.assertNull(result1.getValue());
|
||||
Assertions.assertNull(result2.getValue());
|
||||
}
|
||||
}
|
||||
}
|
@ -30,4 +30,4 @@ public abstract class AbstractCacheFactoryTest {
|
||||
}
|
||||
|
||||
protected abstract AbstractCacheFactory getCacheFactory();
|
||||
}
|
||||
}
|
@ -32,19 +32,19 @@ import static org.hamcrest.core.Is.is;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
public class ExpiringCacheFactoryTest extends AbstractCacheFactoryTest {
|
||||
class ExpiringCacheFactoryTest extends AbstractCacheFactoryTest {
|
||||
|
||||
private static final String EXPIRING_CACHE_URL =
|
||||
"test://test:12/test?cache=expiring&cache.seconds=1&cache.interval=1";
|
||||
|
||||
@Test
|
||||
public void testExpiringCacheFactory() throws Exception {
|
||||
void testExpiringCacheFactory() throws Exception {
|
||||
Cache cache = super.constructCache();
|
||||
assertThat(cache instanceof ExpiringCache, is(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExpiringCacheGetExpired() throws Exception {
|
||||
void testExpiringCacheGetExpired() throws Exception {
|
||||
URL url = URL.valueOf("test://test:12/test?cache=expiring&cache.seconds=1&cache.interval=1");
|
||||
AbstractCacheFactory cacheFactory = getCacheFactory();
|
||||
Invocation invocation = new RpcInvocation();
|
||||
@ -55,7 +55,7 @@ public class ExpiringCacheFactoryTest extends AbstractCacheFactoryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExpiringCacheUnExpired() throws Exception {
|
||||
void testExpiringCacheUnExpired() throws Exception {
|
||||
URL url = URL.valueOf("test://test:12/test?cache=expiring&cache.seconds=0&cache.interval=1");
|
||||
AbstractCacheFactory cacheFactory = getCacheFactory();
|
||||
Invocation invocation = new RpcInvocation();
|
||||
@ -66,7 +66,7 @@ public class ExpiringCacheFactoryTest extends AbstractCacheFactoryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExpiringCache() throws Exception {
|
||||
void testExpiringCache() throws Exception {
|
||||
Cache cache = constructCache();
|
||||
assertThat(cache instanceof ExpiringCache, is(true));
|
||||
|
||||
@ -82,7 +82,7 @@ public class ExpiringCacheFactoryTest extends AbstractCacheFactoryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExpiringCacheExpired() throws Exception {
|
||||
void testExpiringCacheExpired() throws Exception {
|
||||
Cache cache = constructCache();
|
||||
assertThat(cache instanceof ExpiringCache, is(true));
|
||||
|
||||
@ -107,4 +107,4 @@ public class ExpiringCacheFactoryTest extends AbstractCacheFactoryTest {
|
||||
protected AbstractCacheFactory getCacheFactory() {
|
||||
return new ExpiringCacheFactory();
|
||||
}
|
||||
}
|
||||
}
|
@ -29,16 +29,16 @@ import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.core.Is.is;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
public class JCacheFactoryTest extends AbstractCacheFactoryTest {
|
||||
class JCacheFactoryTest extends AbstractCacheFactoryTest {
|
||||
|
||||
@Test
|
||||
public void testJCacheFactory() throws Exception {
|
||||
void testJCacheFactory() throws Exception {
|
||||
Cache cache = super.constructCache();
|
||||
assertThat(cache instanceof JCache, is(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJCacheGetExpired() throws Exception {
|
||||
void testJCacheGetExpired() throws Exception {
|
||||
URL url = URL.valueOf("test://test:12/test?cache=jacache&cache.write.expire=1");
|
||||
AbstractCacheFactory cacheFactory = getCacheFactory();
|
||||
Invocation invocation = new RpcInvocation();
|
||||
@ -52,4 +52,4 @@ public class JCacheFactoryTest extends AbstractCacheFactoryTest {
|
||||
protected AbstractCacheFactory getCacheFactory() {
|
||||
return new JCacheFactory();
|
||||
}
|
||||
}
|
||||
}
|
@ -25,9 +25,9 @@ import org.junit.jupiter.api.Test;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.core.Is.is;
|
||||
|
||||
public class LruCacheFactoryTest extends AbstractCacheFactoryTest{
|
||||
class LruCacheFactoryTest extends AbstractCacheFactoryTest{
|
||||
@Test
|
||||
public void testLruCacheFactory() throws Exception {
|
||||
void testLruCacheFactory() throws Exception {
|
||||
Cache cache = super.constructCache();
|
||||
assertThat(cache instanceof LruCache, is(true));
|
||||
}
|
||||
@ -36,4 +36,4 @@ public class LruCacheFactoryTest extends AbstractCacheFactoryTest{
|
||||
protected AbstractCacheFactory getCacheFactory() {
|
||||
return new LruCacheFactory();
|
||||
}
|
||||
}
|
||||
}
|
@ -25,9 +25,9 @@ import org.junit.jupiter.api.Test;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.core.Is.is;
|
||||
|
||||
public class ThreadLocalCacheFactoryTest extends AbstractCacheFactoryTest {
|
||||
class ThreadLocalCacheFactoryTest extends AbstractCacheFactoryTest {
|
||||
@Test
|
||||
public void testThreadLocalCacheFactory() throws Exception {
|
||||
void testThreadLocalCacheFactory() throws Exception {
|
||||
Cache cache = super.constructCache();
|
||||
assertThat(cache instanceof ThreadLocalCache, is(true));
|
||||
}
|
||||
@ -36,4 +36,4 @@ public class ThreadLocalCacheFactoryTest extends AbstractCacheFactoryTest {
|
||||
protected AbstractCacheFactory getCacheFactory() {
|
||||
return new ThreadLocalCacheFactory();
|
||||
}
|
||||
}
|
||||
}
|
@ -34,7 +34,7 @@ import static org.hamcrest.core.Is.is;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
public class ValidationFilterTest {
|
||||
class ValidationFilterTest {
|
||||
private Invoker<?> invoker = mock(Invoker.class);
|
||||
private Validation validation = mock(Validation.class);
|
||||
private Validator validator = mock(Validator.class);
|
||||
@ -48,7 +48,7 @@ public class ValidationFilterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testItWithNotExistClass() throws Exception {
|
||||
void testItWithNotExistClass() throws Exception {
|
||||
URL url = URL.valueOf("test://test:11/test?validation=true");
|
||||
|
||||
given(validation.getValidator(url)).willThrow(new IllegalStateException("Not found class test, cause: test"));
|
||||
@ -66,7 +66,7 @@ public class ValidationFilterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testItWithExistClass() throws Exception {
|
||||
void testItWithExistClass() throws Exception {
|
||||
URL url = URL.valueOf("test://test:11/test?validation=true");
|
||||
|
||||
given(validation.getValidator(url)).willReturn(validator);
|
||||
@ -83,7 +83,7 @@ public class ValidationFilterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testItWithoutUrlParameters() throws Exception {
|
||||
void testItWithoutUrlParameters() throws Exception {
|
||||
URL url = URL.valueOf("test://test:11/test");
|
||||
|
||||
given(validation.getValidator(url)).willReturn(validator);
|
||||
@ -100,7 +100,7 @@ public class ValidationFilterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testItWhileMethodNameStartWithDollar() throws Exception {
|
||||
void testItWhileMethodNameStartWithDollar() throws Exception {
|
||||
URL url = URL.valueOf("test://test:11/test");
|
||||
|
||||
given(validation.getValidator(url)).willReturn(validator);
|
||||
@ -119,7 +119,7 @@ public class ValidationFilterTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void testItWhileThrowoutRpcException() throws Exception {
|
||||
void testItWhileThrowoutRpcException() throws Exception {
|
||||
Assertions.assertThrows(RpcException.class, () -> {
|
||||
URL url = URL.valueOf("test://test:11/test?validation=true");
|
||||
|
||||
@ -134,4 +134,4 @@ public class ValidationFilterTest {
|
||||
validationFilter.invoke(invoker, invocation);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -28,9 +28,9 @@ import javax.validation.ValidationException;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.core.Is.is;
|
||||
|
||||
public class JValidationTest {
|
||||
class JValidationTest {
|
||||
@Test
|
||||
public void testReturnTypeWithInvalidValidationProvider() {
|
||||
void testReturnTypeWithInvalidValidationProvider() {
|
||||
Assertions.assertThrows(ValidationException.class, () -> {
|
||||
Validation jValidation = new JValidation();
|
||||
URL url = URL.valueOf("test://test:11/org.apache.dubbo.validation.support.jvalidation.JValidation?" +
|
||||
@ -41,10 +41,10 @@ public class JValidationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReturnTypeWithDefaultValidatorProvider() {
|
||||
void testReturnTypeWithDefaultValidatorProvider() {
|
||||
Validation jValidation = new JValidation();
|
||||
URL url = URL.valueOf("test://test:11/org.apache.dubbo.validation.support.jvalidation.JValidation");
|
||||
Validator validator = jValidation.getValidator(url);
|
||||
assertThat(validator instanceof JValidator, is(true));
|
||||
}
|
||||
}
|
||||
}
|
@ -28,9 +28,9 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class JValidatorTest {
|
||||
class JValidatorTest {
|
||||
@Test
|
||||
public void testItWithNonExistMethod() throws Exception {
|
||||
void testItWithNonExistMethod() throws Exception {
|
||||
Assertions.assertThrows(NoSuchMethodException.class, () -> {
|
||||
URL url = URL.valueOf("test://test:11/org.apache.dubbo.validation.support.jvalidation.mock.JValidatorTestTarget");
|
||||
JValidator jValidator = new JValidator(url);
|
||||
@ -39,14 +39,14 @@ public class JValidatorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testItWithExistMethod() throws Exception {
|
||||
void testItWithExistMethod() throws Exception {
|
||||
URL url = URL.valueOf("test://test:11/org.apache.dubbo.validation.support.jvalidation.mock.JValidatorTestTarget");
|
||||
JValidator jValidator = new JValidator(url);
|
||||
jValidator.validate("someMethod1", new Class<?>[]{String.class}, new Object[]{"anything"});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testItWhenItViolatedConstraint() throws Exception {
|
||||
void testItWhenItViolatedConstraint() throws Exception {
|
||||
Assertions.assertThrows(ValidationException.class, () -> {
|
||||
URL url = URL.valueOf("test://test:11/org.apache.dubbo.validation.support.jvalidation.mock.JValidatorTestTarget");
|
||||
JValidator jValidator = new JValidator(url);
|
||||
@ -55,32 +55,32 @@ public class JValidatorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testItWhenItMeetsConstraint() throws Exception {
|
||||
void testItWhenItMeetsConstraint() throws Exception {
|
||||
URL url = URL.valueOf("test://test:11/org.apache.dubbo.validation.support.jvalidation.mock.JValidatorTestTarget");
|
||||
JValidator jValidator = new JValidator(url);
|
||||
jValidator.validate("someMethod2", new Class<?>[]{ValidationParameter.class}, new Object[]{new ValidationParameter("NotBeNull")});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testItWithArrayArg() throws Exception {
|
||||
void testItWithArrayArg() throws Exception {
|
||||
URL url = URL.valueOf("test://test:11/org.apache.dubbo.validation.support.jvalidation.mock.JValidatorTestTarget");
|
||||
JValidator jValidator = new JValidator(url);
|
||||
jValidator.validate("someMethod3", new Class<?>[]{ValidationParameter[].class}, new Object[]{new ValidationParameter[]{new ValidationParameter("parameter")}});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testItWithCollectionArg() throws Exception {
|
||||
void testItWithCollectionArg() throws Exception {
|
||||
URL url = URL.valueOf("test://test:11/org.apache.dubbo.validation.support.jvalidation.mock.JValidatorTestTarget");
|
||||
JValidator jValidator = new JValidator(url);
|
||||
jValidator.validate("someMethod4", new Class<?>[]{List.class}, new Object[]{Arrays.asList("parameter")});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testItWithMapArg() throws Exception {
|
||||
void testItWithMapArg() throws Exception {
|
||||
URL url = URL.valueOf("test://test:11/org.apache.dubbo.validation.support.jvalidation.mock.JValidatorTestTarget");
|
||||
JValidator jValidator = new JValidator(url);
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("key", "value");
|
||||
jValidator.validate("someMethod5", new Class<?>[]{Map.class}, new Object[]{map});
|
||||
}
|
||||
}
|
||||
}
|
@ -51,7 +51,7 @@ import java.util.Map;
|
||||
import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.NAMESPACE;
|
||||
|
||||
@ExtendWith({MockitoExtension.class})
|
||||
public class KubernetesServiceDiscoveryTest {
|
||||
class KubernetesServiceDiscoveryTest {
|
||||
private static final String SERVICE_NAME = "TestService";
|
||||
|
||||
private static final String POD_NAME = "TestServer";
|
||||
@ -120,7 +120,7 @@ public class KubernetesServiceDiscoveryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEndpointsUpdate() throws Exception {
|
||||
void testEndpointsUpdate() throws Exception {
|
||||
serviceDiscovery.setCurrentHostname(POD_NAME);
|
||||
serviceDiscovery.setKubernetesClient(mockClient);
|
||||
|
||||
@ -154,7 +154,7 @@ public class KubernetesServiceDiscoveryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPodsUpdate() throws Exception {
|
||||
void testPodsUpdate() throws Exception {
|
||||
serviceDiscovery.setCurrentHostname(POD_NAME);
|
||||
serviceDiscovery.setKubernetesClient(mockClient);
|
||||
|
||||
@ -182,7 +182,7 @@ public class KubernetesServiceDiscoveryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testServiceUpdate() throws Exception {
|
||||
void testServiceUpdate() throws Exception {
|
||||
serviceDiscovery.setCurrentHostname(POD_NAME);
|
||||
serviceDiscovery.setKubernetesClient(mockClient);
|
||||
|
||||
@ -215,7 +215,7 @@ public class KubernetesServiceDiscoveryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetInstance() {
|
||||
void testGetInstance() {
|
||||
serviceDiscovery.setCurrentHostname(POD_NAME);
|
||||
serviceDiscovery.setKubernetesClient(mockClient);
|
||||
|
||||
@ -230,4 +230,4 @@ public class KubernetesServiceDiscoveryTest {
|
||||
|
||||
serviceDiscovery.doUnregister(serviceInstance);
|
||||
}
|
||||
}
|
||||
}
|
@ -20,10 +20,10 @@ package org.apache.dubbo.metrics.aggregate;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class TimeWindowCounterTest {
|
||||
class TimeWindowCounterTest {
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
void test() throws Exception {
|
||||
TimeWindowCounter counter = new TimeWindowCounter(12, 1);
|
||||
counter.increment();
|
||||
Assertions.assertEquals(counter.get(), 1);
|
||||
@ -34,4 +34,4 @@ public class TimeWindowCounterTest {
|
||||
Assertions.assertEquals(counter.get(), 0);
|
||||
Assertions.assertTrue(counter.bucketLivedSeconds() < 1);
|
||||
}
|
||||
}
|
||||
}
|
@ -20,10 +20,10 @@ package org.apache.dubbo.metrics.aggregate;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class TimeWindowQuantileTest {
|
||||
class TimeWindowQuantileTest {
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
void test() throws Exception {
|
||||
TimeWindowQuantile quantile = new TimeWindowQuantile(100, 12, 1);
|
||||
for (int i = 1; i <= 100; i++) {
|
||||
quantile.add(i);
|
||||
@ -34,4 +34,4 @@ public class TimeWindowQuantileTest {
|
||||
Thread.sleep(1000);
|
||||
Assertions.assertEquals(quantile.quantile(0.99), Double.NaN);
|
||||
}
|
||||
}
|
||||
}
|
@ -25,6 +25,7 @@ import org.apache.dubbo.config.ApplicationConfig;
|
||||
import org.apache.dubbo.config.MetricsConfig;
|
||||
import org.apache.dubbo.config.nested.AggregationConfig;
|
||||
import org.apache.dubbo.rpc.model.ApplicationModel;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@ -34,9 +35,12 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.apache.dubbo.common.constants.MetricsConstants.*;
|
||||
import static org.apache.dubbo.common.constants.MetricsConstants.TAG_GROUP_KEY;
|
||||
import static org.apache.dubbo.common.constants.MetricsConstants.TAG_INTERFACE_KEY;
|
||||
import static org.apache.dubbo.common.constants.MetricsConstants.TAG_METHOD_KEY;
|
||||
import static org.apache.dubbo.common.constants.MetricsConstants.TAG_VERSION_KEY;
|
||||
|
||||
public class AggregateMetricsCollectorTest {
|
||||
class AggregateMetricsCollectorTest {
|
||||
|
||||
private ApplicationModel applicationModel;
|
||||
private DefaultMetricsCollector defaultCollector;
|
||||
@ -77,7 +81,7 @@ public class AggregateMetricsCollectorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequestsMetrics() {
|
||||
void testRequestsMetrics() {
|
||||
AggregateMetricsCollector collector = new AggregateMetricsCollector(applicationModel);
|
||||
defaultCollector.increaseTotalRequests(interfaceName, methodName, group, version);
|
||||
defaultCollector.increaseSucceedRequests(interfaceName, methodName, group, version);
|
||||
@ -109,7 +113,7 @@ public class AggregateMetricsCollectorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRTMetrics() {
|
||||
void testRTMetrics() {
|
||||
AggregateMetricsCollector collector = new AggregateMetricsCollector(applicationModel);
|
||||
defaultCollector.addRT(interfaceName, methodName, group, version, 10L);
|
||||
|
||||
|
@ -17,18 +17,6 @@
|
||||
|
||||
package org.apache.dubbo.metrics.filter;
|
||||
|
||||
import static org.apache.dubbo.common.constants.MetricsConstants.TAG_GROUP_KEY;
|
||||
import static org.apache.dubbo.common.constants.MetricsConstants.TAG_INTERFACE_KEY;
|
||||
import static org.apache.dubbo.common.constants.MetricsConstants.TAG_METHOD_KEY;
|
||||
import static org.apache.dubbo.common.constants.MetricsConstants.TAG_VERSION_KEY;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.dubbo.common.metrics.collector.DefaultMetricsCollector;
|
||||
import org.apache.dubbo.common.metrics.model.MetricsKey;
|
||||
import org.apache.dubbo.common.metrics.model.sample.MetricSample;
|
||||
@ -39,12 +27,25 @@ import org.apache.dubbo.rpc.Result;
|
||||
import org.apache.dubbo.rpc.RpcException;
|
||||
import org.apache.dubbo.rpc.RpcInvocation;
|
||||
import org.apache.dubbo.rpc.model.ApplicationModel;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class MetricsFilterTest {
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.apache.dubbo.common.constants.MetricsConstants.TAG_GROUP_KEY;
|
||||
import static org.apache.dubbo.common.constants.MetricsConstants.TAG_INTERFACE_KEY;
|
||||
import static org.apache.dubbo.common.constants.MetricsConstants.TAG_METHOD_KEY;
|
||||
import static org.apache.dubbo.common.constants.MetricsConstants.TAG_VERSION_KEY;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
class MetricsFilterTest {
|
||||
|
||||
private ApplicationModel applicationModel;
|
||||
private MetricsFilter filter;
|
||||
@ -78,7 +79,7 @@ public class MetricsFilterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCollectDisabled() {
|
||||
void testCollectDisabled() {
|
||||
given(invoker.invoke(invocation)).willReturn(new AppResponse("success"));
|
||||
|
||||
filter.invoke(invoker, invocation);
|
||||
@ -87,7 +88,7 @@ public class MetricsFilterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailedRequests() {
|
||||
void testFailedRequests() {
|
||||
collector.setCollectEnabled(true);
|
||||
given(invoker.invoke(invocation)).willThrow(new RpcException("failed"));
|
||||
initParam();
|
||||
@ -114,7 +115,7 @@ public class MetricsFilterTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void testBusinessFailedRequests() {
|
||||
void testBusinessFailedRequests() {
|
||||
collector.setCollectEnabled(true);
|
||||
|
||||
given(invoker.invoke(invocation)).willThrow(new RpcException(RpcException.BIZ_EXCEPTION));
|
||||
@ -142,7 +143,7 @@ public class MetricsFilterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSucceedRequests() {
|
||||
void testSucceedRequests() {
|
||||
collector.setCollectEnabled(true);
|
||||
given(invoker.invoke(invocation)).willReturn(new AppResponse("success"));
|
||||
initParam();
|
||||
@ -165,7 +166,7 @@ public class MetricsFilterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMissingGroup() {
|
||||
void testMissingGroup() {
|
||||
collector.setCollectEnabled(true);
|
||||
given(invoker.invoke(invocation)).willReturn(new AppResponse("success"));
|
||||
invocation.setTargetServiceUniqueName(INTERFACE_NAME + ":" + VERSION);
|
||||
@ -188,7 +189,7 @@ public class MetricsFilterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMissingVersion() {
|
||||
void testMissingVersion() {
|
||||
collector.setCollectEnabled(true);
|
||||
given(invoker.invoke(invocation)).willReturn(new AppResponse("success"));
|
||||
invocation.setTargetServiceUniqueName(GROUP + "/" + INTERFACE_NAME);
|
||||
@ -211,7 +212,7 @@ public class MetricsFilterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMissingGroupAndVersion() {
|
||||
void testMissingGroupAndVersion() {
|
||||
collector.setCollectEnabled(true);
|
||||
given(invoker.invoke(invocation)).willReturn(new AppResponse("success"));
|
||||
invocation.setTargetServiceUniqueName(INTERFACE_NAME);
|
||||
|
@ -20,13 +20,14 @@ package org.apache.dubbo.metrics.prometheus;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.metrics.MetricsReporter;
|
||||
import org.apache.dubbo.rpc.model.ApplicationModel;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class PrometheusMetricsReporterFactoryTest {
|
||||
class PrometheusMetricsReporterFactoryTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
void test() {
|
||||
ApplicationModel applicationModel = ApplicationModel.defaultModel();
|
||||
PrometheusMetricsReporterFactory factory = new PrometheusMetricsReporterFactory(applicationModel);
|
||||
MetricsReporter reporter = factory.createMetricsReporter(URL.valueOf("prometheus://localhost:9090/"));
|
||||
|
@ -17,11 +17,12 @@
|
||||
|
||||
package org.apache.dubbo.metrics.prometheus;
|
||||
|
||||
import io.micrometer.prometheus.PrometheusMeterRegistry;
|
||||
import org.apache.dubbo.common.utils.NetUtils;
|
||||
import org.apache.dubbo.config.MetricsConfig;
|
||||
import org.apache.dubbo.config.nested.PrometheusConfig;
|
||||
import org.apache.dubbo.rpc.model.ApplicationModel;
|
||||
|
||||
import io.micrometer.prometheus.PrometheusMeterRegistry;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
@ -40,7 +41,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import static org.apache.dubbo.common.constants.MetricsConstants.PROTOCOL_PROMETHEUS;
|
||||
|
||||
public class PrometheusMetricsReporterTest {
|
||||
class PrometheusMetricsReporterTest {
|
||||
|
||||
private MetricsConfig metricsConfig;
|
||||
private ApplicationModel applicationModel;
|
||||
@ -58,7 +59,7 @@ public class PrometheusMetricsReporterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJvmMetrics() {
|
||||
void testJvmMetrics() {
|
||||
metricsConfig.setEnableJvmMetrics(true);
|
||||
PrometheusMetricsReporter reporter = new PrometheusMetricsReporter(metricsConfig.toUrl(), applicationModel);
|
||||
reporter.init();
|
||||
@ -72,7 +73,7 @@ public class PrometheusMetricsReporterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExporter() {
|
||||
void testExporter() {
|
||||
int port = NetUtils.getAvailablePort();
|
||||
|
||||
PrometheusConfig prometheusConfig = new PrometheusConfig();
|
||||
@ -101,7 +102,7 @@ public class PrometheusMetricsReporterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPushgateway() {
|
||||
void testPushgateway() {
|
||||
PrometheusConfig prometheusConfig = new PrometheusConfig();
|
||||
PrometheusConfig.Pushgateway pushgateway = new PrometheusConfig.Pushgateway();
|
||||
pushgateway.setJob("mock");
|
||||
|
@ -29,7 +29,7 @@ import java.util.List;
|
||||
/**
|
||||
* AbstractMonitorFactoryTest
|
||||
*/
|
||||
public class AbstractMonitorFactoryTest {
|
||||
class AbstractMonitorFactoryTest {
|
||||
|
||||
private MonitorFactory monitorFactory = new AbstractMonitorFactory() {
|
||||
|
||||
@ -61,7 +61,7 @@ public class AbstractMonitorFactoryTest {
|
||||
};
|
||||
|
||||
@Test
|
||||
public void testMonitorFactoryCache() throws Exception {
|
||||
void testMonitorFactoryCache() throws Exception {
|
||||
URL url = URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostAddress() + ":2233");
|
||||
Monitor monitor1 = monitorFactory.getMonitor(url);
|
||||
Monitor monitor2 = monitorFactory.getMonitor(url);
|
||||
@ -74,7 +74,7 @@ public class AbstractMonitorFactoryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMonitorFactoryIpCache() throws Exception {
|
||||
void testMonitorFactoryIpCache() throws Exception {
|
||||
URL url = URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostName() + ":2233");
|
||||
Monitor monitor1 = monitorFactory.getMonitor(url);
|
||||
Monitor monitor2 = monitorFactory.getMonitor(url);
|
||||
@ -87,7 +87,7 @@ public class AbstractMonitorFactoryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMonitorFactoryGroupCache() throws Exception {
|
||||
void testMonitorFactoryGroupCache() throws Exception {
|
||||
URL url1 = URL.valueOf("dubbo://" + NetUtils.getLocalHost() + ":2233?group=aaa");
|
||||
URL url2 = URL.valueOf("dubbo://" + NetUtils.getLocalHost() + ":2233?group=bbb");
|
||||
Monitor monitor1 = monitorFactory.getMonitor(url1);
|
||||
@ -100,4 +100,4 @@ public class AbstractMonitorFactoryTest {
|
||||
Assertions.assertNotSame(monitor1, monitor2);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -56,7 +56,7 @@ import static org.mockito.Mockito.verify;
|
||||
/**
|
||||
* MonitorFilterTest
|
||||
*/
|
||||
public class MonitorFilterTest {
|
||||
class MonitorFilterTest {
|
||||
|
||||
private volatile URL lastStatistics;
|
||||
|
||||
@ -114,7 +114,7 @@ public class MonitorFilterTest {
|
||||
};
|
||||
|
||||
@Test
|
||||
public void testFilter() throws Exception {
|
||||
void testFilter() throws Exception {
|
||||
MonitorFilter monitorFilter = new MonitorFilter();
|
||||
monitorFilter.setMonitorFactory(monitorFactory);
|
||||
Invocation invocation = new RpcInvocation("aaa", MonitorService.class.getName(), "", new Class<?>[0], new Object[0]);
|
||||
@ -143,7 +143,7 @@ public class MonitorFilterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSkipMonitorIfNotHasKey() {
|
||||
void testSkipMonitorIfNotHasKey() {
|
||||
MonitorFilter monitorFilter = new MonitorFilter();
|
||||
MonitorFactory mockMonitorFactory = mock(MonitorFactory.class);
|
||||
monitorFilter.setMonitorFactory(mockMonitorFactory);
|
||||
@ -157,7 +157,7 @@ public class MonitorFilterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericFilter() throws Exception {
|
||||
void testGenericFilter() throws Exception {
|
||||
MonitorFilter monitorFilter = new MonitorFilter();
|
||||
monitorFilter.setMonitorFactory(monitorFactory);
|
||||
Invocation invocation = new RpcInvocation("$invoke", MonitorService.class.getName(), "", new Class<?>[]{String.class, String[].class, Object[].class}, new Object[]{"xxx", new String[]{}, new Object[]{}});
|
||||
@ -186,7 +186,7 @@ public class MonitorFilterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSafeFailForMonitorCollectFail() {
|
||||
void testSafeFailForMonitorCollectFail() {
|
||||
MonitorFilter monitorFilter = new MonitorFilter();
|
||||
MonitorFactory mockMonitorFactory = mock(MonitorFactory.class);
|
||||
Monitor mockMonitor = mock(Monitor.class);
|
||||
@ -200,7 +200,7 @@ public class MonitorFilterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnResponseWithoutStartTime() {
|
||||
void testOnResponseWithoutStartTime() {
|
||||
MonitorFilter monitorFilter = new MonitorFilter();
|
||||
MonitorFactory mockMonitorFactory = mock(MonitorFactory.class);
|
||||
Monitor mockMonitor = mock(Monitor.class);
|
||||
@ -215,7 +215,7 @@ public class MonitorFilterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnErrorWithoutStartTime() {
|
||||
void testOnErrorWithoutStartTime() {
|
||||
MonitorFilter monitorFilter = new MonitorFilter();
|
||||
MonitorFactory mockMonitorFactory = mock(MonitorFactory.class);
|
||||
Monitor mockMonitor = mock(Monitor.class);
|
||||
@ -226,4 +226,4 @@ public class MonitorFilterTest {
|
||||
Throwable rpcException = new RpcException();
|
||||
monitorFilter.onError(rpcException, serviceInvoker, invocation);
|
||||
}
|
||||
}
|
||||
}
|
@ -36,7 +36,7 @@ import static org.mockito.Mockito.atLeastOnce;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.MockitoAnnotations.initMocks;
|
||||
|
||||
public class DubboMonitorFactoryTest {
|
||||
class DubboMonitorFactoryTest {
|
||||
private DubboMonitorFactory dubboMonitorFactory;
|
||||
@Mock
|
||||
private ProxyFactory proxyFactory;
|
||||
@ -50,7 +50,7 @@ public class DubboMonitorFactoryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateMonitor() {
|
||||
void testCreateMonitor() {
|
||||
URL urlWithoutPath = URL.valueOf("http://10.10.10.11");
|
||||
Monitor monitor = dubboMonitorFactory.createMonitor(urlWithoutPath);
|
||||
assertThat(monitor, not(nullValue()));
|
||||
@ -65,4 +65,4 @@ public class DubboMonitorFactoryTest {
|
||||
Invoker invoker = invokerArgumentCaptor.getValue();
|
||||
assertThat(invoker.getUrl().getParameter(REFERENCE_FILTER_KEY), containsString("testFilter"));
|
||||
}
|
||||
}
|
||||
}
|
@ -65,7 +65,7 @@ import static org.mockito.Mockito.verify;
|
||||
/**
|
||||
* DubboMonitorTest
|
||||
*/
|
||||
public class DubboMonitorTest {
|
||||
class DubboMonitorTest {
|
||||
|
||||
private final Invoker<MonitorService> monitorInvoker = new Invoker<MonitorService>() {
|
||||
@Override
|
||||
@ -105,7 +105,7 @@ public class DubboMonitorTest {
|
||||
};
|
||||
|
||||
@Test
|
||||
public void testCount() throws Exception {
|
||||
void testCount() throws Exception {
|
||||
DubboMonitor monitor = new DubboMonitor(monitorInvoker, monitorService);
|
||||
URL statistics = new URLBuilder(DUBBO_PROTOCOL, "10.20.153.10", 0)
|
||||
.addParameter(APPLICATION_KEY, "morgan")
|
||||
@ -141,7 +141,7 @@ public class DubboMonitorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMonitorFactory() throws Exception {
|
||||
void testMonitorFactory() throws Exception {
|
||||
MockMonitorService monitorService = new MockMonitorService();
|
||||
URL statistics = new URLBuilder(DUBBO_PROTOCOL, "10.20.153.10", 0)
|
||||
.addParameter(APPLICATION_KEY, "morgan")
|
||||
@ -191,7 +191,7 @@ public class DubboMonitorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAvailable() {
|
||||
void testAvailable() {
|
||||
Invoker invoker = mock(Invoker.class);
|
||||
MonitorService monitorService = mock(MonitorService.class);
|
||||
|
||||
@ -204,7 +204,7 @@ public class DubboMonitorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSum() {
|
||||
void testSum() {
|
||||
URL statistics = new URLBuilder(DUBBO_PROTOCOL, "10.20.153.11", 0)
|
||||
.addParameter(APPLICATION_KEY, "morgan")
|
||||
.addParameter(INTERFACE_KEY, "MemberService")
|
||||
@ -246,7 +246,7 @@ public class DubboMonitorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLookUp() {
|
||||
void testLookUp() {
|
||||
Invoker invoker = mock(Invoker.class);
|
||||
MonitorService monitorService = mock(MonitorService.class);
|
||||
|
||||
@ -258,4 +258,4 @@ public class DubboMonitorTest {
|
||||
|
||||
verify(monitorService).lookup(eq(queryUrl));
|
||||
}
|
||||
}
|
||||
}
|
@ -65,7 +65,7 @@ import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
public class MetricsFilterTest {
|
||||
class MetricsFilterTest {
|
||||
private int port = NetUtils.getAvailablePort(20880 + new Random().nextInt(10000));
|
||||
|
||||
private final Function<URL, Invoker<DemoService>> invokerFunction = (url) -> {
|
||||
@ -93,7 +93,7 @@ public class MetricsFilterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAll() {
|
||||
void testAll() {
|
||||
List<Callable<Void>> testcases = new LinkedList<>();
|
||||
testcases.add(() -> {
|
||||
testConsumerSuccess();
|
||||
@ -353,4 +353,4 @@ public class MetricsFilterTest {
|
||||
Assertions.assertEquals(50.0 / 100.0,
|
||||
methodMetricMap.get("org.apache.dubbo.monitor.dubbo.service.DemoService.void echo(Integer)").get("success_rate"));
|
||||
}
|
||||
}
|
||||
}
|
@ -40,9 +40,9 @@ import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
|
||||
public class StatisticsTest {
|
||||
class StatisticsTest {
|
||||
@Test
|
||||
public void testEquals() {
|
||||
void testEquals() {
|
||||
URL statistics = new URLBuilder(DUBBO_PROTOCOL, "10.20.153.10", 0)
|
||||
.addParameter(APPLICATION_KEY, "morgan")
|
||||
.addParameter(INTERFACE_KEY, "MemberService")
|
||||
@ -76,7 +76,7 @@ public class StatisticsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
void testToString() {
|
||||
Statistics statistics = new Statistics(new ServiceConfigURL("dubbo", "10.20.153.10", 0));
|
||||
statistics.setApplication("demo");
|
||||
statistics.setMethod("findPerson");
|
||||
@ -106,4 +106,4 @@ public class StatisticsTest {
|
||||
MatcherAssert.assertThat(statisticsWithDetailInfo.getGroup(), equalTo(statistics.getGroup()));
|
||||
MatcherAssert.assertThat(statisticsWithDetailInfo, not(equalTo(statistics)));
|
||||
}
|
||||
}
|
||||
}
|
@ -134,4 +134,4 @@ class AccessKeyAuthenticatorTest {
|
||||
String signature1 = helper.getSignature(url, invocation, secretKey, String.valueOf(System.currentTimeMillis()));
|
||||
assertNotEquals(signature, signature1);
|
||||
}
|
||||
}
|
||||
}
|
@ -40,4 +40,4 @@ class DefaultAccessKeyStorageTest {
|
||||
assertEquals(accessKey.getAccessKey(), "ak");
|
||||
assertEquals(accessKey.getSecretKey(), "sk");
|
||||
}
|
||||
}
|
||||
}
|
@ -61,4 +61,4 @@ class ConsumerSignFilterTest {
|
||||
consumerSignFilter.invoke(invoker, invocation);
|
||||
verify(invocation, times(1)).setAttachment(eq(Constants.REQUEST_SIGNATURE_KEY), anyString());
|
||||
}
|
||||
}
|
||||
}
|
@ -187,4 +187,4 @@ class ProviderAuthFilterTest {
|
||||
Result result = providerAuthFilter.invoke(invoker, invocation);
|
||||
assertNull(result);
|
||||
}
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SignatureUtilsTest {
|
||||
class SignatureUtilsTest {
|
||||
|
||||
@Test
|
||||
void testEncryptWithObject() {
|
||||
@ -35,4 +35,4 @@ public class SignatureUtilsTest {
|
||||
String encryptWithNoParams = SignatureUtils.sign(null, "TestMethod#hello", "TOKEN");
|
||||
Assertions.assertEquals(encryptWithNoParams, "2DGkTcyXg4plU24rY8MZkEJwOMRW3o+wUP3HssRc3EE=");
|
||||
}
|
||||
}
|
||||
}
|
@ -24,9 +24,9 @@ import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class CommandContextFactoryTest {
|
||||
class CommandContextFactoryTest {
|
||||
@Test
|
||||
public void testNewInstance() throws Exception {
|
||||
void testNewInstance() throws Exception {
|
||||
CommandContext context = CommandContextFactory.newInstance("test");
|
||||
assertThat(context.getCommandName(), equalTo("test"));
|
||||
context = CommandContextFactory.newInstance("command", new String[]{"hello"}, true);
|
||||
@ -34,4 +34,4 @@ public class CommandContextFactoryTest {
|
||||
assertThat(context.getArgs(), Matchers.arrayContaining("hello"));
|
||||
assertTrue(context.isHttp());
|
||||
}
|
||||
}
|
||||
}
|
@ -28,9 +28,9 @@ import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class CommandContextTest {
|
||||
class CommandContextTest {
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
void test() throws Exception {
|
||||
CommandContext context = new CommandContext("test", new String[]{"hello"}, true);
|
||||
Object request = new Object();
|
||||
context.setOriginRequest(request);
|
||||
@ -53,4 +53,4 @@ public class CommandContextTest {
|
||||
assertFalse(context.isHttp());
|
||||
assertThat(context.getRemote(), is(channel));
|
||||
}
|
||||
}
|
||||
}
|
@ -25,9 +25,9 @@ import org.junit.jupiter.api.Test;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
public class DefaultCommandExecutorTest {
|
||||
class DefaultCommandExecutorTest {
|
||||
@Test
|
||||
public void testExecute1() throws Exception {
|
||||
void testExecute1() throws Exception {
|
||||
Assertions.assertThrows(NoSuchCommandException.class, () -> {
|
||||
DefaultCommandExecutor executor = new DefaultCommandExecutor(FrameworkModel.defaultModel());
|
||||
executor.execute(CommandContextFactory.newInstance("not-exit"));
|
||||
@ -35,9 +35,9 @@ public class DefaultCommandExecutorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecute2() throws Exception {
|
||||
void testExecute2() throws Exception {
|
||||
DefaultCommandExecutor executor = new DefaultCommandExecutor(FrameworkModel.defaultModel());
|
||||
String result = executor.execute(CommandContextFactory.newInstance("greeting", new String[]{"dubbo"}, false));
|
||||
assertThat(result, equalTo("greeting dubbo"));
|
||||
}
|
||||
}
|
||||
}
|
@ -35,9 +35,9 @@ import static org.hamcrest.Matchers.is;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class HttpCommandDecoderTest {
|
||||
class HttpCommandDecoderTest {
|
||||
@Test
|
||||
public void decodeGet() throws Exception {
|
||||
void decodeGet() throws Exception {
|
||||
HttpRequest request = mock(HttpRequest.class);
|
||||
when(request.uri()).thenReturn("localhost:80/test");
|
||||
when(request.method()).thenReturn(HttpMethod.GET);
|
||||
@ -50,7 +50,7 @@ public class HttpCommandDecoderTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodePost() throws Exception {
|
||||
void decodePost() throws Exception {
|
||||
FullHttpRequest request = mock(FullHttpRequest.class);
|
||||
when(request.uri()).thenReturn("localhost:80/test");
|
||||
when(request.method()).thenReturn(HttpMethod.POST);
|
||||
@ -62,4 +62,4 @@ public class HttpCommandDecoderTest {
|
||||
assertThat(context.isHttp(), is(true));
|
||||
assertThat(context.getArgs(), arrayContaining("b", "d"));
|
||||
}
|
||||
}
|
||||
}
|
@ -25,12 +25,12 @@ import static org.hamcrest.Matchers.arrayContaining;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
public class TelnetCommandDecoderTest {
|
||||
class TelnetCommandDecoderTest {
|
||||
@Test
|
||||
public void testDecode() throws Exception {
|
||||
void testDecode() throws Exception {
|
||||
CommandContext context = TelnetCommandDecoder.decode("test a b");
|
||||
assertThat(context.getCommandName(), equalTo("test"));
|
||||
assertThat(context.isHttp(), is(false));
|
||||
assertThat(context.getArgs(), arrayContaining("a", "b"));
|
||||
}
|
||||
}
|
||||
}
|
@ -39,7 +39,7 @@ import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.reset;
|
||||
|
||||
public class ChangeTelnetTest {
|
||||
class ChangeTelnetTest {
|
||||
private final DefaultAttributeMap defaultAttributeMap = new DefaultAttributeMap();
|
||||
private BaseCommand change;
|
||||
|
||||
@ -80,14 +80,14 @@ public class ChangeTelnetTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeSimpleName() {
|
||||
void testChangeSimpleName() {
|
||||
ExtensionLoader.getExtensionLoader(Protocol.class).getExtension(DubboProtocol.NAME).export(mockInvoker);
|
||||
String result = change.execute(mockCommandContext, new String[]{"DemoService"});
|
||||
assertEquals("Used the DemoService as default.\r\nYou can cancel default service by command: cd /", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeName() {
|
||||
void testChangeName() {
|
||||
ExtensionLoader.getExtensionLoader(Protocol.class).getExtension(DubboProtocol.NAME).export(mockInvoker);
|
||||
String result = change.execute(mockCommandContext, new String[]{"org.apache.dubbo.qos.legacy.service.DemoService"});
|
||||
assertEquals("Used the org.apache.dubbo.qos.legacy.service.DemoService as default.\r\nYou can cancel default service by command: cd /",
|
||||
@ -95,33 +95,33 @@ public class ChangeTelnetTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangePath() {
|
||||
void testChangePath() {
|
||||
ExtensionLoader.getExtensionLoader(Protocol.class).getExtension(DubboProtocol.NAME).export(mockInvoker);
|
||||
String result = change.execute(mockCommandContext, new String[]{"demo"});
|
||||
assertEquals("Used the demo as default.\r\nYou can cancel default service by command: cd /", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeMessageNull() {
|
||||
void testChangeMessageNull() {
|
||||
String result = change.execute(mockCommandContext, null);
|
||||
assertEquals("Please input service name, eg: \r\ncd XxxService\r\ncd com.xxx.XxxService", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeServiceNotExport() {
|
||||
void testChangeServiceNotExport() {
|
||||
String result = change.execute(mockCommandContext, new String[]{"demo"});
|
||||
assertEquals("No such service demo", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeCancel() {
|
||||
void testChangeCancel() {
|
||||
String result = change.execute(mockCommandContext, new String[]{".."});
|
||||
assertEquals("Cancelled default service org.apache.dubbo.rpc.protocol.dubbo.support.DemoService.", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeCancel2() {
|
||||
void testChangeCancel2() {
|
||||
String result = change.execute(mockCommandContext, new String[]{"/"});
|
||||
assertEquals("Cancelled default service org.apache.dubbo.rpc.protocol.dubbo.support.DemoService.", result);
|
||||
}
|
||||
}
|
||||
}
|
@ -43,7 +43,7 @@ import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.reset;
|
||||
|
||||
public class CountTelnetTest {
|
||||
class CountTelnetTest {
|
||||
private BaseCommand count;
|
||||
|
||||
private MockNettyChannel mockChannel;
|
||||
@ -75,7 +75,7 @@ public class CountTelnetTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
void test() throws Exception {
|
||||
String methodName = "sayHello";
|
||||
String[] args = new String[]{"org.apache.dubbo.qos.legacy.service.DemoService", "sayHello", "1"};
|
||||
|
||||
@ -118,4 +118,4 @@ public class CountTelnetTest {
|
||||
return TelnetUtils.toTable(header, table);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -25,9 +25,9 @@ import org.mockito.Mockito;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
||||
public class HelpTest {
|
||||
class HelpTest {
|
||||
@Test
|
||||
public void testMainHelp() throws Exception {
|
||||
void testMainHelp() throws Exception {
|
||||
Help help = new Help(FrameworkModel.defaultModel());
|
||||
String output = help.execute(Mockito.mock(CommandContext.class), null);
|
||||
assertThat(output, containsString("greeting"));
|
||||
@ -39,7 +39,7 @@ public class HelpTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGreeting() throws Exception {
|
||||
void testGreeting() throws Exception {
|
||||
Help help = new Help(FrameworkModel.defaultModel());
|
||||
String output = help.execute(Mockito.mock(CommandContext.class), new String[]{"greeting"});
|
||||
assertThat(output, containsString("COMMAND NAME"));
|
||||
@ -47,4 +47,4 @@ public class HelpTest {
|
||||
assertThat(output, containsString("EXAMPLE"));
|
||||
assertThat(output, containsString("greeting dubbo"));
|
||||
}
|
||||
}
|
||||
}
|
@ -39,7 +39,7 @@ import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.reset;
|
||||
|
||||
public class InvokeTelnetTest {
|
||||
class InvokeTelnetTest {
|
||||
|
||||
private FrameworkModel frameworkModel;
|
||||
private BaseCommand invoke;
|
||||
@ -69,7 +69,7 @@ public class InvokeTelnetTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvokeWithoutServicePrefixAndWithoutDefaultService() throws RemotingException {
|
||||
void testInvokeWithoutServicePrefixAndWithoutDefaultService() throws RemotingException {
|
||||
registerProvider(DemoService.class.getName(), new DemoServiceImpl(), DemoService.class);
|
||||
String result = invoke.execute(mockCommandContext, new String[]{"echo(\"ok\")"});
|
||||
assertTrue(result.contains("If you want to invoke like [invoke sayHello(\"xxxx\")], please execute cd command first," +
|
||||
@ -77,7 +77,7 @@ public class InvokeTelnetTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvokeDefaultService() throws RemotingException {
|
||||
void testInvokeDefaultService() throws RemotingException {
|
||||
defaultAttributeMap.attr(ChangeTelnet.SERVICE_KEY).set(DemoService.class.getName());
|
||||
defaultAttributeMap.attr(SelectTelnet.SELECT_KEY).set(null);
|
||||
given(mockChannel.attr(ChangeTelnet.SERVICE_KEY)).willReturn(defaultAttributeMap.attr(ChangeTelnet.SERVICE_KEY));
|
||||
@ -90,7 +90,7 @@ public class InvokeTelnetTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvokeWithSpecifyService() throws RemotingException {
|
||||
void testInvokeWithSpecifyService() throws RemotingException {
|
||||
defaultAttributeMap.attr(ChangeTelnet.SERVICE_KEY).set(null);
|
||||
defaultAttributeMap.attr(SelectTelnet.SELECT_KEY).set(null);
|
||||
|
||||
@ -105,7 +105,7 @@ public class InvokeTelnetTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvokeByPassingNullValue() {
|
||||
void testInvokeByPassingNullValue() {
|
||||
defaultAttributeMap.attr(ChangeTelnet.SERVICE_KEY).set(DemoService.class.getName());
|
||||
defaultAttributeMap.attr(SelectTelnet.SELECT_KEY).set(null);
|
||||
given(mockChannel.attr(ChangeTelnet.SERVICE_KEY)).willReturn(defaultAttributeMap.attr(ChangeTelnet.SERVICE_KEY));
|
||||
@ -123,7 +123,7 @@ public class InvokeTelnetTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvokeByPassingEnumValue() throws RemotingException {
|
||||
void testInvokeByPassingEnumValue() throws RemotingException {
|
||||
defaultAttributeMap.attr(ChangeTelnet.SERVICE_KEY).set(DemoService.class.getName());
|
||||
defaultAttributeMap.attr(SelectTelnet.SELECT_KEY).set(null);
|
||||
|
||||
@ -139,7 +139,7 @@ public class InvokeTelnetTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOverriddenMethodWithSpecifyParamType() throws RemotingException {
|
||||
void testOverriddenMethodWithSpecifyParamType() throws RemotingException {
|
||||
defaultAttributeMap.attr(ChangeTelnet.SERVICE_KEY).set(DemoService.class.getName());
|
||||
defaultAttributeMap.attr(SelectTelnet.SELECT_KEY).set(null);
|
||||
given(mockChannel.attr(ChangeTelnet.SERVICE_KEY)).willReturn(defaultAttributeMap.attr(ChangeTelnet.SERVICE_KEY));
|
||||
@ -156,7 +156,7 @@ public class InvokeTelnetTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvokeOverriddenMethodBySelect() throws RemotingException {
|
||||
void testInvokeOverriddenMethodBySelect() throws RemotingException {
|
||||
defaultAttributeMap.attr(ChangeTelnet.SERVICE_KEY).set(DemoService.class.getName());
|
||||
defaultAttributeMap.attr(SelectTelnet.SELECT_KEY).set(null);
|
||||
defaultAttributeMap.attr(SelectTelnet.SELECT_METHOD_KEY).set(null);
|
||||
@ -191,7 +191,7 @@ public class InvokeTelnetTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvokeMethodWithMapParameter() throws RemotingException {
|
||||
void testInvokeMethodWithMapParameter() throws RemotingException {
|
||||
defaultAttributeMap.attr(ChangeTelnet.SERVICE_KEY).set(DemoService.class.getName());
|
||||
defaultAttributeMap.attr(SelectTelnet.SELECT_KEY).set(null);
|
||||
|
||||
@ -209,7 +209,7 @@ public class InvokeTelnetTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvokeMultiJsonParamMethod() throws RemotingException {
|
||||
void testInvokeMultiJsonParamMethod() throws RemotingException {
|
||||
defaultAttributeMap.attr(ChangeTelnet.SERVICE_KEY).set(DemoService.class.getName());
|
||||
defaultAttributeMap.attr(SelectTelnet.SELECT_KEY).set(null);
|
||||
|
||||
@ -227,7 +227,7 @@ public class InvokeTelnetTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMessageNull() throws RemotingException {
|
||||
void testMessageNull() throws RemotingException {
|
||||
defaultAttributeMap.attr(ChangeTelnet.SERVICE_KEY).set(null);
|
||||
defaultAttributeMap.attr(SelectTelnet.SELECT_KEY).set(null);
|
||||
|
||||
@ -243,7 +243,7 @@ public class InvokeTelnetTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidMessage() throws RemotingException {
|
||||
void testInvalidMessage() throws RemotingException {
|
||||
defaultAttributeMap.attr(ChangeTelnet.SERVICE_KEY).set(null);
|
||||
defaultAttributeMap.attr(SelectTelnet.SELECT_KEY).set(null);
|
||||
|
||||
@ -267,4 +267,4 @@ public class InvokeTelnetTest {
|
||||
null
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class LiveTest {
|
||||
class LiveTest {
|
||||
private FrameworkModel frameworkModel;
|
||||
|
||||
@BeforeEach
|
||||
@ -38,7 +38,7 @@ public class LiveTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecute() {
|
||||
void testExecute() {
|
||||
Live live = new Live(frameworkModel);
|
||||
CommandContext commandContext = new CommandContext("live");
|
||||
String result = live.execute(commandContext, new String[0]);
|
||||
@ -50,4 +50,4 @@ public class LiveTest {
|
||||
Assertions.assertEquals(result, "true");
|
||||
Assertions.assertEquals(commandContext.getHttpCode(), 200);
|
||||
}
|
||||
}
|
||||
}
|
@ -37,7 +37,7 @@ import org.mockito.Mockito;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class LsTest {
|
||||
class LsTest {
|
||||
private FrameworkModel frameworkModel;
|
||||
private ModuleServiceRepository repository;
|
||||
|
||||
@ -55,7 +55,7 @@ public class LsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecute() {
|
||||
void testExecute() {
|
||||
Ls ls = new Ls(frameworkModel);
|
||||
String result = ls.execute(Mockito.mock(CommandContext.class), new String[0]);
|
||||
System.out.println(result);
|
||||
@ -100,4 +100,4 @@ public class LsTest {
|
||||
serviceMetadata, methodConfigs, referenceConfig.getInterfaceClassLoader());
|
||||
repository.registerConsumer(consumerModel);
|
||||
}
|
||||
}
|
||||
}
|
@ -43,7 +43,7 @@ import static org.mockito.Mockito.mock;
|
||||
* {@link OfflineApp}
|
||||
* {@link OfflineInterface}
|
||||
*/
|
||||
public class OfflineTest {
|
||||
class OfflineTest {
|
||||
private FrameworkModel frameworkModel;
|
||||
private ModuleServiceRepository repository;
|
||||
private ProviderModel.RegisterStatedURL registerStatedURL;
|
||||
@ -61,7 +61,7 @@ public class OfflineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecute() {
|
||||
void testExecute() {
|
||||
Offline offline = new Offline(frameworkModel);
|
||||
String result = offline.execute(mock(CommandContext.class), new String[]{DemoService.class.getName()});
|
||||
Assertions.assertEquals(result, "OK");
|
||||
@ -100,4 +100,4 @@ public class OfflineTest {
|
||||
);
|
||||
repository.registerProvider(providerModel);
|
||||
}
|
||||
}
|
||||
}
|
@ -43,7 +43,7 @@ import static org.mockito.Mockito.mock;
|
||||
* {@link OnlineApp}
|
||||
* {@link OnlineInterface}
|
||||
*/
|
||||
public class OnlineTest {
|
||||
class OnlineTest {
|
||||
private FrameworkModel frameworkModel;
|
||||
private ModuleServiceRepository repository;
|
||||
private ProviderModel.RegisterStatedURL registerStatedURL;
|
||||
@ -61,7 +61,7 @@ public class OnlineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecute() {
|
||||
void testExecute() {
|
||||
Online online = new Online(frameworkModel);
|
||||
String result = online.execute(mock(CommandContext.class), new String[]{DemoService.class.getName()});
|
||||
Assertions.assertEquals(result, "OK");
|
||||
@ -100,4 +100,4 @@ public class OnlineTest {
|
||||
);
|
||||
repository.registerProvider(providerModel);
|
||||
}
|
||||
}
|
||||
}
|
@ -39,7 +39,7 @@ import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.reset;
|
||||
|
||||
public class PortTelnetTest {
|
||||
class PortTelnetTest {
|
||||
private BaseCommand port;
|
||||
|
||||
private Invoker<DemoService> mockInvoker;
|
||||
@ -71,7 +71,7 @@ public class PortTelnetTest {
|
||||
* the address converted by NAT. In this case, check port only.
|
||||
*/
|
||||
@Test
|
||||
public void testListClient() throws Exception {
|
||||
void testListClient() throws Exception {
|
||||
ExchangeClient client1 = Exchangers.connect("dubbo://127.0.0.1:" + availablePort + "/demo");
|
||||
ExchangeClient client2 = Exchangers.connect("dubbo://127.0.0.1:" + availablePort + "/demo");
|
||||
Thread.sleep(100);
|
||||
@ -86,26 +86,26 @@ public class PortTelnetTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListDetail() throws RemotingException {
|
||||
void testListDetail() throws RemotingException {
|
||||
String result = port.execute(mockCommandContext, new String[]{"-l"});
|
||||
assertEquals("dubbo://127.0.0.1:" + availablePort + "", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListAllPort() throws RemotingException {
|
||||
void testListAllPort() throws RemotingException {
|
||||
String result = port.execute(mockCommandContext, new String[0]);
|
||||
assertEquals("" + availablePort + "", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testErrorMessage() throws RemotingException {
|
||||
void testErrorMessage() throws RemotingException {
|
||||
String result = port.execute(mockCommandContext, new String[]{"a"});
|
||||
assertEquals("Illegal port a, must be integer.", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoPort() throws RemotingException {
|
||||
void testNoPort() throws RemotingException {
|
||||
String result = port.execute(mockCommandContext, new String[]{"-l", "20880"});
|
||||
assertEquals("No such port 20880", result);
|
||||
}
|
||||
}
|
||||
}
|
@ -27,7 +27,7 @@ import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
public class PublishMetadataTest {
|
||||
class PublishMetadataTest {
|
||||
private FrameworkModel frameworkModel;
|
||||
|
||||
@BeforeEach
|
||||
@ -46,7 +46,7 @@ public class PublishMetadataTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecute() {
|
||||
void testExecute() {
|
||||
PublishMetadata publishMetadata = new PublishMetadata(frameworkModel);
|
||||
|
||||
String result = publishMetadata.execute(Mockito.mock(CommandContext.class), new String[0]);
|
||||
@ -68,4 +68,4 @@ public class PublishMetadataTest {
|
||||
Assertions.assertEquals(result, expectResult);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -32,7 +32,7 @@ import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.reset;
|
||||
|
||||
public class PwdTelnetTest {
|
||||
class PwdTelnetTest {
|
||||
private static final BaseCommand pwdTelnet = new PwdTelnet();
|
||||
private Channel mockChannel;
|
||||
private CommandContext mockCommandContext;
|
||||
@ -55,23 +55,23 @@ public class PwdTelnetTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testService() throws RemotingException {
|
||||
void testService() throws RemotingException {
|
||||
defaultAttributeMap.attr(ChangeTelnet.SERVICE_KEY).set("org.apache.dubbo.rpc.protocol.dubbo.support.DemoService");
|
||||
String result = pwdTelnet.execute(mockCommandContext, new String[0]);
|
||||
assertEquals("org.apache.dubbo.rpc.protocol.dubbo.support.DemoService", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSlash() throws RemotingException {
|
||||
void testSlash() throws RemotingException {
|
||||
defaultAttributeMap.attr(ChangeTelnet.SERVICE_KEY).set(null);
|
||||
String result = pwdTelnet.execute(mockCommandContext, new String[0]);
|
||||
assertEquals("/", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMessageError() throws RemotingException {
|
||||
void testMessageError() throws RemotingException {
|
||||
defaultAttributeMap.attr(ChangeTelnet.SERVICE_KEY).set(null);
|
||||
String result = pwdTelnet.execute(mockCommandContext, new String[]{"test"});
|
||||
assertEquals("Unsupported parameter [test] for pwd.", result);
|
||||
}
|
||||
}
|
||||
}
|
@ -25,11 +25,11 @@ import org.mockito.Mockito;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
public class QuitTest {
|
||||
class QuitTest {
|
||||
@Test
|
||||
public void testExecute() throws Exception {
|
||||
void testExecute() throws Exception {
|
||||
Quit quit = new Quit();
|
||||
String output = quit.execute(Mockito.mock(CommandContext.class), null);
|
||||
assertThat(output, equalTo(QosConstants.CLOSE));
|
||||
}
|
||||
}
|
||||
}
|
@ -41,7 +41,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class ReadyTest {
|
||||
class ReadyTest {
|
||||
|
||||
private FrameworkModel frameworkModel;
|
||||
private ModuleDeployer moduleDeployer;
|
||||
@ -76,7 +76,7 @@ public class ReadyTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecute() {
|
||||
void testExecute() {
|
||||
Ready ready = new Ready(frameworkModel);
|
||||
CommandContext commandContext = new CommandContext("ready");
|
||||
|
||||
@ -89,4 +89,4 @@ public class ReadyTest {
|
||||
Assertions.assertEquals("false", result);
|
||||
Assertions.assertEquals(commandContext.getHttpCode(), 503);
|
||||
}
|
||||
}
|
||||
}
|
@ -42,7 +42,7 @@ import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.reset;
|
||||
|
||||
public class SelectTelnetTest {
|
||||
class SelectTelnetTest {
|
||||
|
||||
private BaseCommand select;
|
||||
|
||||
@ -78,7 +78,7 @@ public class SelectTelnetTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvokeWithoutMethodList() throws RemotingException {
|
||||
void testInvokeWithoutMethodList() throws RemotingException {
|
||||
defaultAttributeMap.attr(ChangeTelnet.SERVICE_KEY).set(DemoService.class.getName());
|
||||
defaultAttributeMap.attr(InvokeTelnet.INVOKE_METHOD_LIST_KEY).set(null);
|
||||
|
||||
@ -95,7 +95,7 @@ public class SelectTelnetTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvokeWithIllegalMessage() throws RemotingException {
|
||||
void testInvokeWithIllegalMessage() throws RemotingException {
|
||||
defaultAttributeMap.attr(ChangeTelnet.SERVICE_KEY).set(DemoService.class.getName());
|
||||
defaultAttributeMap.attr(InvokeTelnet.INVOKE_METHOD_LIST_KEY).set(methods);
|
||||
|
||||
@ -118,7 +118,7 @@ public class SelectTelnetTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvokeWithNull() throws RemotingException {
|
||||
void testInvokeWithNull() throws RemotingException {
|
||||
defaultAttributeMap.attr(ChangeTelnet.SERVICE_KEY).set(DemoService.class.getName());
|
||||
defaultAttributeMap.attr(InvokeTelnet.INVOKE_METHOD_LIST_KEY).set(methods);
|
||||
|
||||
@ -144,4 +144,4 @@ public class SelectTelnetTest {
|
||||
null
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -31,7 +31,7 @@ import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.reset;
|
||||
|
||||
public class ShutdownTelnetTest {
|
||||
class ShutdownTelnetTest {
|
||||
|
||||
private BaseCommand shutdown;
|
||||
private Channel mockChannel;
|
||||
@ -52,13 +52,13 @@ public class ShutdownTelnetTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvoke() throws RemotingException {
|
||||
void testInvoke() throws RemotingException {
|
||||
String result = shutdown.execute(mockCommandContext, new String[0]);
|
||||
assertTrue(result.contains("Application has shutdown successfully"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvokeWithTimeParameter() throws RemotingException {
|
||||
void testInvokeWithTimeParameter() throws RemotingException {
|
||||
int sleepTime = 2000;
|
||||
long start = System.currentTimeMillis();
|
||||
String result = shutdown.execute(mockCommandContext, new String[]{"-t", "" + sleepTime});
|
||||
@ -66,4 +66,4 @@ public class ShutdownTelnetTest {
|
||||
assertTrue(result.contains("Application has shutdown successfully"), result);
|
||||
assertTrue((end - start) >= sleepTime, "sleepTime: " + sleepTime + ", execTime: " + (end - start));
|
||||
}
|
||||
}
|
||||
}
|
@ -38,7 +38,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class StartupTest {
|
||||
class StartupTest {
|
||||
private FrameworkModel frameworkModel;
|
||||
private ModuleDeployer moduleDeployer;
|
||||
|
||||
@ -67,7 +67,7 @@ public class StartupTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecute() {
|
||||
void testExecute() {
|
||||
Startup startup = new Startup(frameworkModel);
|
||||
CommandContext commandContext = new CommandContext("startup");
|
||||
|
||||
@ -80,4 +80,4 @@ public class StartupTest {
|
||||
Assertions.assertEquals("false", result);
|
||||
Assertions.assertEquals(commandContext.getHttpCode(), 503);
|
||||
}
|
||||
}
|
||||
}
|
@ -65,17 +65,17 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class CommandHelperTest {
|
||||
class CommandHelperTest {
|
||||
private CommandHelper commandHelper = new CommandHelper(FrameworkModel.defaultModel());
|
||||
|
||||
@Test
|
||||
public void testHasCommand() throws Exception {
|
||||
void testHasCommand() throws Exception {
|
||||
assertTrue(commandHelper.hasCommand("greeting"));
|
||||
assertFalse(commandHelper.hasCommand("not-exiting"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAllCommandClass() throws Exception {
|
||||
void testGetAllCommandClass() throws Exception {
|
||||
List<Class<?>> classes = commandHelper.getAllCommandClass();
|
||||
|
||||
// update this list when introduce a new command
|
||||
@ -119,8 +119,8 @@ public class CommandHelperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCommandClass() throws Exception {
|
||||
void testGetCommandClass() throws Exception {
|
||||
assertThat(commandHelper.getCommandClass("greeting"), equalTo(GreetingCommand.class));
|
||||
assertNull(commandHelper.getCommandClass("not-exiting"));
|
||||
}
|
||||
}
|
||||
}
|
@ -47,12 +47,12 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
/**
|
||||
* Test for ServiceCheckUtils
|
||||
*/
|
||||
public class ServiceCheckUtilsTest {
|
||||
class ServiceCheckUtilsTest {
|
||||
|
||||
private final ModuleServiceRepository repository = ApplicationModel.defaultModel().getDefaultModule().getServiceRepository();
|
||||
|
||||
@Test
|
||||
public void testIsRegistered() {
|
||||
void testIsRegistered() {
|
||||
DemoService demoServiceImpl = new DemoServiceImpl();
|
||||
|
||||
int availablePort = NetUtils.getAvailablePort();
|
||||
@ -77,7 +77,7 @@ public class ServiceCheckUtilsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetConsumerAddressNum() {
|
||||
void testGetConsumerAddressNum() {
|
||||
ConsumerModel consumerModel = Mockito.mock(ConsumerModel.class);
|
||||
ServiceMetadata serviceMetadata = Mockito.mock(ServiceMetadata.class);
|
||||
Mockito.when(consumerModel.getServiceMetadata()).thenReturn(serviceMetadata);
|
||||
@ -144,4 +144,4 @@ public class ServiceCheckUtilsTest {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -40,7 +40,7 @@ import static org.mockito.Mockito.reset;
|
||||
/**
|
||||
* ChangeTelnetHandlerTest.java
|
||||
*/
|
||||
public class ChangeTelnetHandlerTest {
|
||||
class ChangeTelnetHandlerTest {
|
||||
|
||||
private static TelnetHandler change = new ChangeTelnetHandler();
|
||||
private Channel mockChannel;
|
||||
@ -80,14 +80,14 @@ public class ChangeTelnetHandlerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeSimpleName() throws RemotingException {
|
||||
void testChangeSimpleName() throws RemotingException {
|
||||
ExtensionLoader.getExtensionLoader(Protocol.class).getExtension(DubboProtocol.NAME).export(mockInvoker);
|
||||
String result = change.telnet(mockChannel, "DemoService");
|
||||
assertEquals("Used the DemoService as default.\r\nYou can cancel default service by command: cd /", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeName() throws RemotingException {
|
||||
void testChangeName() throws RemotingException {
|
||||
ExtensionLoader.getExtensionLoader(Protocol.class).getExtension(DubboProtocol.NAME).export(mockInvoker);
|
||||
String result = change.telnet(mockChannel, "org.apache.dubbo.qos.legacy.service.DemoService");
|
||||
assertEquals("Used the org.apache.dubbo.qos.legacy.service.DemoService as default.\r\nYou can cancel default service by command: cd /",
|
||||
@ -95,33 +95,33 @@ public class ChangeTelnetHandlerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangePath() throws RemotingException {
|
||||
void testChangePath() throws RemotingException {
|
||||
ExtensionLoader.getExtensionLoader(Protocol.class).getExtension(DubboProtocol.NAME).export(mockInvoker);
|
||||
String result = change.telnet(mockChannel, "demo");
|
||||
assertEquals("Used the demo as default.\r\nYou can cancel default service by command: cd /", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeMessageNull() throws RemotingException {
|
||||
void testChangeMessageNull() throws RemotingException {
|
||||
String result = change.telnet(mockChannel, null);
|
||||
assertEquals("Please input service name, eg: \r\ncd XxxService\r\ncd com.xxx.XxxService", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeServiceNotExport() throws RemotingException {
|
||||
void testChangeServiceNotExport() throws RemotingException {
|
||||
String result = change.telnet(mockChannel, "demo");
|
||||
assertEquals("No such service demo", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeCancel() throws RemotingException {
|
||||
void testChangeCancel() throws RemotingException {
|
||||
String result = change.telnet(mockChannel, "..");
|
||||
assertEquals("Cancelled default service org.apache.dubbo.rpc.protocol.dubbo.support.DemoService.", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeCancel2() throws RemotingException {
|
||||
void testChangeCancel2() throws RemotingException {
|
||||
String result = change.telnet(mockChannel, "/");
|
||||
assertEquals("Cancelled default service org.apache.dubbo.rpc.protocol.dubbo.support.DemoService.", result);
|
||||
}
|
||||
}
|
||||
}
|
@ -28,13 +28,13 @@ import static org.mockito.Mockito.mock;
|
||||
/**
|
||||
* LogTelnetHandlerTest.java
|
||||
*/
|
||||
public class LogTelnetHandlerTest {
|
||||
class LogTelnetHandlerTest {
|
||||
|
||||
private static TelnetHandler log = new LogTelnetHandler();
|
||||
private Channel mockChannel;
|
||||
|
||||
@Test
|
||||
public void testChangeLogLevel() throws RemotingException {
|
||||
void testChangeLogLevel() throws RemotingException {
|
||||
mockChannel = mock(Channel.class);
|
||||
|
||||
String result = log.telnet(mockChannel, "error");
|
||||
@ -44,11 +44,11 @@ public class LogTelnetHandlerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrintLog() throws RemotingException {
|
||||
void testPrintLog() throws RemotingException {
|
||||
mockChannel = mock(Channel.class);
|
||||
|
||||
String result = log.telnet(mockChannel, "100");
|
||||
assertTrue(result.contains("CURRENT LOG APPENDER"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -40,7 +40,7 @@ import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.reset;
|
||||
|
||||
public class TraceTelnetHandlerTest {
|
||||
class TraceTelnetHandlerTest {
|
||||
|
||||
private TelnetHandler handler;
|
||||
private Channel mockChannel;
|
||||
@ -63,7 +63,7 @@ public class TraceTelnetHandlerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTraceTelnetAddTracer() throws Exception {
|
||||
void testTraceTelnetAddTracer() throws Exception {
|
||||
String method = "sayHello";
|
||||
String message = "org.apache.dubbo.qos.legacy.service.DemoService sayHello 1";
|
||||
Class<?> type = DemoService.class;
|
||||
@ -82,4 +82,4 @@ public class TraceTelnetHandlerTest {
|
||||
|
||||
Assertions.assertTrue(channels.contains(mockChannel));
|
||||
}
|
||||
}
|
||||
}
|
@ -50,10 +50,10 @@ import static org.apache.dubbo.common.constants.CommonConstants.GENERIC_SERIALIZ
|
||||
* GenericServiceTest
|
||||
*/
|
||||
@Disabled("Keeps failing on Travis, but can not be reproduced locally.")
|
||||
public class GenericServiceTest {
|
||||
class GenericServiceTest {
|
||||
|
||||
@Test
|
||||
public void testGenericServiceException() {
|
||||
void testGenericServiceException() {
|
||||
ServiceConfig<GenericService> service = new ServiceConfig<GenericService>();
|
||||
service.setInterface(DemoService.class.getName());
|
||||
service.setRef(new GenericService() {
|
||||
@ -109,7 +109,7 @@ public class GenericServiceTest {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testGenericReferenceException() {
|
||||
void testGenericReferenceException() {
|
||||
ServiceConfig<DemoService> service = new ServiceConfig<DemoService>();
|
||||
service.setInterface(DemoService.class.getName());
|
||||
service.setRef(new DemoServiceImpl());
|
||||
@ -146,7 +146,7 @@ public class GenericServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericSerializationJava() throws Exception {
|
||||
void testGenericSerializationJava() throws Exception {
|
||||
ServiceConfig<DemoService> service = new ServiceConfig<DemoService>();
|
||||
service.setInterface(DemoService.class.getName());
|
||||
DemoServiceImpl ref = new DemoServiceImpl();
|
||||
@ -216,7 +216,7 @@ public class GenericServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericInvokeWithBeanSerialization() throws Exception {
|
||||
void testGenericInvokeWithBeanSerialization() throws Exception {
|
||||
ServiceConfig<DemoService> service = new ServiceConfig<DemoService>();
|
||||
service.setInterface(DemoService.class);
|
||||
DemoServiceImpl impl = new DemoServiceImpl();
|
||||
@ -256,7 +256,7 @@ public class GenericServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenericImplementationWithBeanSerialization() throws Exception {
|
||||
void testGenericImplementationWithBeanSerialization() throws Exception {
|
||||
final AtomicReference reference = new AtomicReference();
|
||||
|
||||
ServiceConfig<GenericService> service = new ServiceConfig<GenericService>();
|
||||
@ -332,4 +332,4 @@ public class GenericServiceTest {
|
||||
Object[] arguments;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -23,6 +23,7 @@ import org.apache.dubbo.qos.server.Server;
|
||||
import org.apache.dubbo.rpc.Invoker;
|
||||
import org.apache.dubbo.rpc.Protocol;
|
||||
import org.apache.dubbo.rpc.model.FrameworkModel;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -39,7 +40,7 @@ import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class QosProtocolWrapperTest {
|
||||
class QosProtocolWrapperTest {
|
||||
private URL url = Mockito.mock(URL.class);
|
||||
private Invoker invoker = mock(Invoker.class);
|
||||
private Protocol protocol = mock(Protocol.class);
|
||||
@ -87,7 +88,7 @@ public class QosProtocolWrapperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExport() throws Exception {
|
||||
void testExport() throws Exception {
|
||||
wrapper.export(invoker);
|
||||
assertThat(server.isStarted(), is(true));
|
||||
assertThat(server.getHost(), is("localhost"));
|
||||
@ -97,7 +98,7 @@ public class QosProtocolWrapperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRefer() throws Exception {
|
||||
void testRefer() throws Exception {
|
||||
wrapper.refer(BaseCommand.class, url);
|
||||
assertThat(server.isStarted(), is(true));
|
||||
assertThat(server.getHost(), is("localhost"));
|
||||
@ -107,7 +108,7 @@ public class QosProtocolWrapperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiProtocol() throws Exception {
|
||||
void testMultiProtocol() throws Exception {
|
||||
//tri protocol start first, acceptForeignIp = true
|
||||
triWrapper.export(triInvoker);
|
||||
assertThat(server.isStarted(), is(true));
|
||||
|
@ -35,9 +35,9 @@ import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class HttpProcessHandlerTest {
|
||||
class HttpProcessHandlerTest {
|
||||
@Test
|
||||
public void test1() throws Exception {
|
||||
void test1() throws Exception {
|
||||
ChannelHandlerContext context = mock(ChannelHandlerContext.class);
|
||||
ChannelFuture future = mock(ChannelFuture.class);
|
||||
when(context.writeAndFlush(any(FullHttpResponse.class))).thenReturn(future);
|
||||
@ -53,7 +53,7 @@ public class HttpProcessHandlerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2() throws Exception {
|
||||
void test2() throws Exception {
|
||||
ChannelHandlerContext context = mock(ChannelHandlerContext.class);
|
||||
ChannelFuture future = mock(ChannelFuture.class);
|
||||
when(context.writeAndFlush(any(FullHttpResponse.class))).thenReturn(future);
|
||||
@ -70,7 +70,7 @@ public class HttpProcessHandlerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test3() throws Exception {
|
||||
void test3() throws Exception {
|
||||
ChannelHandlerContext context = mock(ChannelHandlerContext.class);
|
||||
ChannelFuture future = mock(ChannelFuture.class);
|
||||
when(context.writeAndFlush(any(FullHttpResponse.class))).thenReturn(future);
|
||||
@ -85,4 +85,4 @@ public class HttpProcessHandlerTest {
|
||||
FullHttpResponse response = captor.getValue();
|
||||
assertThat(response.status().code(), equalTo(404));
|
||||
}
|
||||
}
|
||||
}
|
@ -34,9 +34,9 @@ import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class LocalHostPermitHandlerTest {
|
||||
class LocalHostPermitHandlerTest {
|
||||
@Test
|
||||
public void testHandlerAdded() throws Exception {
|
||||
void testHandlerAdded() throws Exception {
|
||||
ChannelHandlerContext context = mock(ChannelHandlerContext.class);
|
||||
Channel channel = mock(Channel.class);
|
||||
when(context.channel()).thenReturn(channel);
|
||||
@ -53,4 +53,4 @@ public class LocalHostPermitHandlerTest {
|
||||
assertThat(new String(captor.getValue().array()), containsString("Foreign Ip Not Permitted"));
|
||||
verify(future).addListener(ChannelFutureListener.CLOSE);
|
||||
}
|
||||
}
|
||||
}
|
@ -35,9 +35,9 @@ import java.util.Collections;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
public class QosProcessHandlerTest {
|
||||
class QosProcessHandlerTest {
|
||||
@Test
|
||||
public void testDecodeHttp() throws Exception {
|
||||
void testDecodeHttp() throws Exception {
|
||||
ByteBuf buf = Unpooled.wrappedBuffer(new byte[] {'G'});
|
||||
ChannelHandlerContext context = Mockito.mock(ChannelHandlerContext.class);
|
||||
ChannelPipeline pipeline = Mockito.mock(ChannelPipeline.class);
|
||||
@ -51,7 +51,7 @@ public class QosProcessHandlerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecodeTelnet() throws Exception {
|
||||
void testDecodeTelnet() throws Exception {
|
||||
ByteBuf buf = Unpooled.wrappedBuffer(new byte[] {'A'});
|
||||
ChannelHandlerContext context = Mockito.mock(ChannelHandlerContext.class);
|
||||
ChannelPipeline pipeline = Mockito.mock(ChannelPipeline.class);
|
||||
@ -66,4 +66,4 @@ public class QosProcessHandlerTest {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -32,9 +32,9 @@ import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class TelnetProcessHandlerTest {
|
||||
class TelnetProcessHandlerTest {
|
||||
@Test
|
||||
public void testPrompt() throws Exception {
|
||||
void testPrompt() throws Exception {
|
||||
ChannelHandlerContext context = mock(ChannelHandlerContext.class);
|
||||
TelnetProcessHandler handler = new TelnetProcessHandler(FrameworkModel.defaultModel());
|
||||
handler.channelRead0(context, "");
|
||||
@ -42,7 +42,7 @@ public class TelnetProcessHandlerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBye() throws Exception {
|
||||
void testBye() throws Exception {
|
||||
ChannelHandlerContext context = mock(ChannelHandlerContext.class);
|
||||
TelnetProcessHandler handler = new TelnetProcessHandler(FrameworkModel.defaultModel());
|
||||
ChannelFuture future = mock(ChannelFuture.class);
|
||||
@ -52,7 +52,7 @@ public class TelnetProcessHandlerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnknownCommand() throws Exception {
|
||||
void testUnknownCommand() throws Exception {
|
||||
ChannelHandlerContext context = mock(ChannelHandlerContext.class);
|
||||
TelnetProcessHandler handler = new TelnetProcessHandler(FrameworkModel.defaultModel());
|
||||
handler.channelRead0(context, "unknown");
|
||||
@ -62,7 +62,7 @@ public class TelnetProcessHandlerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGreeting() throws Exception {
|
||||
void testGreeting() throws Exception {
|
||||
ChannelHandlerContext context = mock(ChannelHandlerContext.class);
|
||||
TelnetProcessHandler handler = new TelnetProcessHandler(FrameworkModel.defaultModel());
|
||||
handler.channelRead0(context, "greeting");
|
||||
@ -71,4 +71,4 @@ public class TelnetProcessHandlerTest {
|
||||
assertThat(captor.getValue(), containsString("greeting"));
|
||||
assertThat(captor.getValue(), containsString("dubbo>"));
|
||||
}
|
||||
}
|
||||
}
|
@ -21,9 +21,9 @@ import org.junit.jupiter.api.Test;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
||||
public class TKvTest {
|
||||
class TKvTest {
|
||||
@Test
|
||||
public void test1() {
|
||||
void test1() {
|
||||
TKv tKv = new TKv(new TTable.ColumnDefine(TTable.Align.RIGHT), new TTable.ColumnDefine(10, false, TTable.Align.LEFT));
|
||||
tKv.add("KEY-1", "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
tKv.add("KEY-2", "1234567890");
|
||||
@ -48,7 +48,7 @@ public class TKvTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2() throws Exception {
|
||||
void test2() throws Exception {
|
||||
TKv tKv = new TKv();
|
||||
tKv.add("KEY-1", "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
tKv.add("KEY-2", "1234567890");
|
||||
@ -57,4 +57,4 @@ public class TKvTest {
|
||||
assertThat(kv, containsString("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
|
||||
System.out.println(kv);
|
||||
}
|
||||
}
|
||||
}
|
@ -21,9 +21,9 @@ import org.junit.jupiter.api.Test;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
public class TLadderTest {
|
||||
class TLadderTest {
|
||||
@Test
|
||||
public void testRendering() throws Exception {
|
||||
void testRendering() throws Exception {
|
||||
TLadder ladder = new TLadder();
|
||||
ladder.addItem("1");
|
||||
ladder.addItem("2");
|
||||
@ -37,4 +37,4 @@ public class TLadderTest {
|
||||
assertThat(result, equalTo(expected));
|
||||
System.out.println(result);
|
||||
}
|
||||
}
|
||||
}
|
@ -21,9 +21,9 @@ import org.junit.jupiter.api.Test;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
public class TTableTest {
|
||||
class TTableTest {
|
||||
@Test
|
||||
public void test1() throws Exception {
|
||||
void test1() throws Exception {
|
||||
TTable table = new TTable(4);
|
||||
table.addRow(1, "one", "uno", "un");
|
||||
table.addRow(2, "two", "dos", "deux");
|
||||
@ -38,7 +38,7 @@ public class TTableTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2() throws Exception {
|
||||
void test2() throws Exception {
|
||||
TTable table = new TTable(new TTable.ColumnDefine[]{
|
||||
new TTable.ColumnDefine(5, true, TTable.Align.LEFT),
|
||||
new TTable.ColumnDefine(10, false, TTable.Align.MIDDLE),
|
||||
@ -52,4 +52,4 @@ public class TTableTest {
|
||||
assertThat(result, equalTo(expected));
|
||||
System.out.println(result);
|
||||
}
|
||||
}
|
||||
}
|
@ -21,9 +21,9 @@ import org.junit.jupiter.api.Test;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
public class TTreeTest {
|
||||
class TTreeTest {
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
void test() throws Exception {
|
||||
TTree tree = new TTree(false, "root");
|
||||
tree.begin("one").begin("ONE").end().end();
|
||||
tree.begin("two").begin("TWO").end().begin("2").end().end();
|
||||
@ -39,4 +39,4 @@ public class TTreeTest {
|
||||
assertThat(result, equalTo(expected));
|
||||
System.out.println(result);
|
||||
}
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ package org.apache.dubbo.reactive;
|
||||
import org.apache.dubbo.common.stream.StreamObserver;
|
||||
import org.apache.dubbo.reactive.handler.ManyToManyMethodHandler;
|
||||
import org.apache.dubbo.rpc.protocol.tri.observer.ServerCallToObserverAdapter;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
@ -38,7 +39,7 @@ import static org.mockito.Mockito.doAnswer;
|
||||
public final class ManyToManyMethodHandlerTest {
|
||||
|
||||
@Test
|
||||
public void testInvoke() throws ExecutionException, InterruptedException {
|
||||
void testInvoke() throws ExecutionException, InterruptedException {
|
||||
AtomicInteger nextCounter = new AtomicInteger();
|
||||
AtomicInteger completeCounter = new AtomicInteger();
|
||||
AtomicInteger errorCounter = new AtomicInteger();
|
||||
|
@ -20,6 +20,7 @@ package org.apache.dubbo.reactive;
|
||||
import org.apache.dubbo.common.stream.StreamObserver;
|
||||
import org.apache.dubbo.reactive.handler.ManyToOneMethodHandler;
|
||||
import org.apache.dubbo.rpc.protocol.tri.observer.ServerCallToObserverAdapter;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
@ -38,7 +39,7 @@ import static org.mockito.Mockito.doAnswer;
|
||||
public final class ManyToOneMethodHandlerTest {
|
||||
|
||||
@Test
|
||||
public void testInvoker() throws ExecutionException, InterruptedException {
|
||||
void testInvoker() throws ExecutionException, InterruptedException {
|
||||
AtomicInteger nextCounter = new AtomicInteger();
|
||||
AtomicInteger completeCounter = new AtomicInteger();
|
||||
AtomicInteger errorCounter = new AtomicInteger();
|
||||
@ -63,7 +64,7 @@ public final class ManyToOneMethodHandlerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testError() throws ExecutionException, InterruptedException {
|
||||
void testError() throws ExecutionException, InterruptedException {
|
||||
AtomicInteger nextCounter = new AtomicInteger();
|
||||
AtomicInteger completeCounter = new AtomicInteger();
|
||||
AtomicInteger errorCounter = new AtomicInteger();
|
||||
|
@ -19,6 +19,7 @@ package org.apache.dubbo.reactive;
|
||||
|
||||
import org.apache.dubbo.reactive.handler.OneToManyMethodHandler;
|
||||
import org.apache.dubbo.rpc.protocol.tri.observer.ServerCallToObserverAdapter;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
@ -37,7 +38,7 @@ import static org.mockito.Mockito.doAnswer;
|
||||
public final class OneToManyMethodHandlerTest {
|
||||
|
||||
@Test
|
||||
public void testInvoke() {
|
||||
void testInvoke() {
|
||||
String request = "1,2,3,4,5,6,7";
|
||||
AtomicInteger nextCounter = new AtomicInteger();
|
||||
AtomicInteger completeCounter = new AtomicInteger();
|
||||
@ -59,7 +60,7 @@ public final class OneToManyMethodHandlerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testError() {
|
||||
void testError() {
|
||||
String request = "1,2,3,4,5,6,7";
|
||||
AtomicInteger nextCounter = new AtomicInteger();
|
||||
AtomicInteger completeCounter = new AtomicInteger();
|
||||
|
@ -18,6 +18,7 @@
|
||||
package org.apache.dubbo.reactive;
|
||||
|
||||
import org.apache.dubbo.reactive.handler.OneToOneMethodHandler;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@ -31,7 +32,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
public final class OneToOneMethodHandlerTest {
|
||||
|
||||
@Test
|
||||
public void testInvoke() throws ExecutionException, InterruptedException {
|
||||
void testInvoke() throws ExecutionException, InterruptedException {
|
||||
String request = "request";
|
||||
OneToOneMethodHandler<String, String> handler = new OneToOneMethodHandler<>(requestMono ->
|
||||
requestMono.map(r -> r + "Test"));
|
||||
|
@ -83,7 +83,7 @@ import java.util.function.Supplier;
|
||||
})
|
||||
@EnableAutoConfiguration
|
||||
@Disabled
|
||||
public class DubboEndpointAnnotationAutoConfigurationTest {
|
||||
class DubboEndpointAnnotationAutoConfigurationTest {
|
||||
|
||||
@Autowired
|
||||
private DubboMetadataEndpoint dubboEndpoint;
|
||||
@ -122,7 +122,7 @@ public class DubboEndpointAnnotationAutoConfigurationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShutdown() throws Exception {
|
||||
void testShutdown() throws Exception {
|
||||
|
||||
Map<String, Object> value = dubboShutdownEndpoint.shutdown();
|
||||
|
||||
@ -136,7 +136,7 @@ public class DubboEndpointAnnotationAutoConfigurationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigs() {
|
||||
void testConfigs() {
|
||||
|
||||
Map<String, Map<String, Map<String, Object>>> configsMap = dubboConfigsMetadataEndpoint.configs();
|
||||
|
||||
@ -173,7 +173,7 @@ public class DubboEndpointAnnotationAutoConfigurationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testServices() {
|
||||
void testServices() {
|
||||
|
||||
Map<String, Map<String, Object>> services = dubboServicesMetadataEndpoint.services();
|
||||
|
||||
@ -186,7 +186,7 @@ public class DubboEndpointAnnotationAutoConfigurationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReferences() {
|
||||
void testReferences() {
|
||||
|
||||
Map<String, Map<String, Object>> references = dubboReferencesMetadataEndpoint.references();
|
||||
|
||||
@ -200,7 +200,7 @@ public class DubboEndpointAnnotationAutoConfigurationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProperties() {
|
||||
void testProperties() {
|
||||
|
||||
SortedMap<String, Object> properties = dubboPropertiesEndpoint.properties();
|
||||
|
||||
@ -219,7 +219,7 @@ public class DubboEndpointAnnotationAutoConfigurationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHttpEndpoints() throws JsonProcessingException {
|
||||
void testHttpEndpoints() throws JsonProcessingException {
|
||||
// testHttpEndpoint("/dubbo", dubboEndpoint::invoke);
|
||||
testHttpEndpoint("/dubbo/configs", dubboConfigsMetadataEndpoint::configs);
|
||||
testHttpEndpoint("/dubbo/services", dubboServicesMetadataEndpoint::services);
|
||||
@ -261,4 +261,4 @@ public class DubboEndpointAnnotationAutoConfigurationTest {
|
||||
private DemoService demoService;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -49,7 +49,7 @@ import static org.apache.dubbo.common.Version.getVersion;
|
||||
}
|
||||
)
|
||||
@EnableAutoConfiguration
|
||||
public class DubboEndpointTest {
|
||||
class DubboEndpointTest {
|
||||
|
||||
|
||||
@Autowired
|
||||
@ -66,7 +66,7 @@ public class DubboEndpointTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvoke() {
|
||||
void testInvoke() {
|
||||
|
||||
Map<String, Object> metadata = dubboEndpoint.invoke();
|
||||
|
||||
@ -90,4 +90,4 @@ public class DubboEndpointTest {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -42,7 +42,7 @@ import static com.alibaba.spring.util.PropertySourcesUtils.getSubProperties;
|
||||
@RunWith(SpringRunner.class)
|
||||
@TestPropertySource(locations = "classpath:/dubbo.properties")
|
||||
@ContextConfiguration(classes = BinderDubboConfigBinder.class)
|
||||
public class BinderDubboConfigBinderTest {
|
||||
class BinderDubboConfigBinderTest {
|
||||
|
||||
@Autowired
|
||||
private ConfigurationBeanBinder dubboConfigBinder;
|
||||
@ -51,7 +51,7 @@ public class BinderDubboConfigBinderTest {
|
||||
private ConfigurableEnvironment environment;
|
||||
|
||||
@Test
|
||||
public void testBinder() {
|
||||
void testBinder() {
|
||||
|
||||
ApplicationConfig applicationConfig = new ApplicationConfig();
|
||||
Map<String, Object> properties = getSubProperties(environment.getPropertySources(), "dubbo.application");
|
||||
@ -69,4 +69,4 @@ public class BinderDubboConfigBinderTest {
|
||||
dubboConfigBinder.bind(properties, true, true, protocolConfig);
|
||||
Assert.assertEquals(Integer.valueOf(20881), protocolConfig.getPort());
|
||||
}
|
||||
}
|
||||
}
|
@ -52,7 +52,7 @@ import static org.junit.Assert.assertTrue;
|
||||
})
|
||||
@EnableAutoConfiguration
|
||||
@PropertySource(value = "classpath:/dubbo.properties")
|
||||
public class DubboRelaxedBinding2AutoConfigurationTest {
|
||||
class DubboRelaxedBinding2AutoConfigurationTest {
|
||||
|
||||
@Autowired
|
||||
@Qualifier(BASE_PACKAGES_BEAN_NAME)
|
||||
@ -75,7 +75,7 @@ public class DubboRelaxedBinding2AutoConfigurationTest {
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Test
|
||||
public void testBeans() {
|
||||
void testBeans() {
|
||||
|
||||
|
||||
assertTrue(ClassUtils.isAssignableValue(BinderDubboConfigBinder.class, dubboConfigBinder));
|
||||
@ -95,4 +95,4 @@ public class DubboRelaxedBinding2AutoConfigurationTest {
|
||||
assertTrue(environments.containsValue(environment));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -30,7 +30,7 @@ import java.util.HashMap;
|
||||
/**
|
||||
* {@link DubboDefaultPropertiesEnvironmentPostProcessor} Test
|
||||
*/
|
||||
public class DubboDefaultPropertiesEnvironmentPostProcessorTest {
|
||||
class DubboDefaultPropertiesEnvironmentPostProcessorTest {
|
||||
|
||||
private DubboDefaultPropertiesEnvironmentPostProcessor instance =
|
||||
new DubboDefaultPropertiesEnvironmentPostProcessor();
|
||||
@ -38,12 +38,12 @@ public class DubboDefaultPropertiesEnvironmentPostProcessorTest {
|
||||
private SpringApplication springApplication = new SpringApplication();
|
||||
|
||||
@Test
|
||||
public void testOrder() {
|
||||
void testOrder() {
|
||||
Assert.assertEquals(Ordered.LOWEST_PRECEDENCE, instance.getOrder());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPostProcessEnvironment() {
|
||||
void testPostProcessEnvironment() {
|
||||
MockEnvironment environment = new MockEnvironment();
|
||||
// Case 1 : Not Any property
|
||||
instance.postProcessEnvironment(environment, springApplication);
|
||||
@ -94,4 +94,4 @@ public class DubboDefaultPropertiesEnvironmentPostProcessorTest {
|
||||
Assert.assertEquals("false", environment.getProperty("dubbo.config.multiple"));
|
||||
Assert.assertEquals("false", environment.getProperty("dubbo.application.qos-enable"));
|
||||
}
|
||||
}
|
||||
}
|
@ -16,19 +16,20 @@
|
||||
*/
|
||||
package org.apache.dubbo.registry.xds.util.bootstrap;
|
||||
|
||||
import io.grpc.netty.shaded.io.netty.channel.unix.DomainSocketAddress;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.url.component.URLAddress;
|
||||
import org.apache.dubbo.registry.xds.XdsInitializationException;
|
||||
|
||||
import io.grpc.netty.shaded.io.netty.channel.unix.DomainSocketAddress;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class BootstrapperTest {
|
||||
class BootstrapperTest {
|
||||
@Test
|
||||
public void testParse() throws XdsInitializationException {
|
||||
void testParse() throws XdsInitializationException {
|
||||
String rawData = "{\n" +
|
||||
" \"xds_servers\": [\n" +
|
||||
" {\n" +
|
||||
@ -133,7 +134,7 @@ public class BootstrapperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUrl() {
|
||||
void testUrl() {
|
||||
URL url = URL.valueOf("dubbo://127.0.0.1:23456/TestService?useAgent=true");
|
||||
Assertions.assertTrue(url.getParameter("useAgent", false));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user