[incubator-dubbo] branch master updated: [Dubbo-1691] Add unit tests for MulticastRegister #1691 (#1738)
This is an automated email from the ASF dual-hosted git repository. wangxin pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git The following commit(s) were added to refs/heads/master by this push: new 8b55a0b [Dubbo-1691] Add unit tests for MulticastRegister #1691 (#1738) 8b55a0b is described below commit 8b55a0b31e1c7f9b7d6df5171865bbc11a4d8544 Author: Song Kun AuthorDate: Fri Jun 8 11:41:08 2018 +0800 [Dubbo-1691] Add unit tests for MulticastRegister #1691 (#1738) * Add unit tests for MulticastRegister, add some comments and fix some typo. * Update MulticastRegistryTest.java * Update MulticastRegistryTest.java update code review error --- .../alibaba/dubbo/registry/RegistryService.java| 2 +- .../registry/multicast/MulticastRegistry.java | 6 + .../registry/multicast/MulticastRegistryTest.java | 125 ++--- 3 files changed, 115 insertions(+), 18 deletions(-) diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/RegistryService.java b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/RegistryService.java index 764c5d5..2494d1e 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/RegistryService.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/dubbo/registry/RegistryService.java @@ -54,7 +54,7 @@ public interface RegistryService { void unregister(URL url); /** - * Subscrib to eligible registered data and automatically push when the registered data is changed. + * Subscribe to eligible registered data and automatically push when the registered data is changed. * * Subscribing need to support contracts: * 1. When the URL sets the check=false parameter. When the registration fails, the exception is not thrown and retried in the background. diff --git a/dubbo-registry/dubbo-registry-multicast/src/main/java/com/alibaba/dubbo/registry/multicast/MulticastRegistry.java b/dubbo-registry/dubbo-registry-multicast/src/main/java/com/alibaba/dubbo/registry/multicast/MulticastRegistry.java index d392839..bdb124b 100644 --- a/dubbo-registry/dubbo-registry-multicast/src/main/java/com/alibaba/dubbo/registry/multicast/MulticastRegistry.java +++ b/dubbo-registry/dubbo-registry-multicast/src/main/java/com/alibaba/dubbo/registry/multicast/MulticastRegistry.java @@ -145,6 +145,9 @@ public class MulticastRegistry extends FailbackRegistry { return false; } +/** + * Remove the expired providers, only when "clean" parameter is true. + */ private void clean() { if (admin) { for (Set providers : new HashSet>(received.values())) { @@ -299,6 +302,9 @@ public class MulticastRegistry extends FailbackRegistry { } } +/** + * Remove the expired providers(if clean is true), leave the multicast group and close the multicast socket. + */ @Override public void destroy() { super.destroy(); diff --git a/dubbo-registry/dubbo-registry-multicast/src/test/java/com/alibaba/dubbo/registry/multicast/MulticastRegistryTest.java b/dubbo-registry/dubbo-registry-multicast/src/test/java/com/alibaba/dubbo/registry/multicast/MulticastRegistryTest.java index 3870d54..30fca7e 100644 --- a/dubbo-registry/dubbo-registry-multicast/src/test/java/com/alibaba/dubbo/registry/multicast/MulticastRegistryTest.java +++ b/dubbo-registry/dubbo-registry-multicast/src/test/java/com/alibaba/dubbo/registry/multicast/MulticastRegistryTest.java @@ -27,12 +27,12 @@ import java.net.MulticastSocket; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.concurrent.atomic.AtomicReference; import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertEquals; public class MulticastRegistryTest { @@ -44,31 +44,38 @@ public class MulticastRegistryTest { private URL consumerUrl = URL.valueOf("subscribe://" + NetUtils.getLocalHost() + "/" + service + "?arg1=1=2"); private MulticastRegistry registry = new MulticastRegistry(registryUrl); -/** - * @throws java.lang.Exception - */ @Before -public void setUp() throws Exception { +public void setUp() { registry.register(serviceUrl); } +/** + * Test method for {@link com.alibaba.dubbo.registry.multicast.MulticastRegistry#MulticastRegistry(URL)}. + */ @Test(expected = IllegalArgumentException.class) public void testUrlError() { URL errorUrl = URL.valueOf("multicast://mullticast/"); new MulticastRegistry(errorUrl); } +/** + * Test method for {@link
[incubator-dubbo] branch master updated: support resolves property values. (#1895)
This is an automated email from the ASF dual-hosted git repository. mercyblitz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git The following commit(s) were added to refs/heads/master by this push: new c459f6c support resolves property values. (#1895) c459f6c is described below commit c459f6c9afc43154fd9a9838f2dc96297dd0ce4d Author: wuwen AuthorDate: Fri Jun 8 11:12:31 2018 +0800 support resolves property values. (#1895) Ok for me --- .../alibaba/dubbo/config/spring/util/PropertySourcesUtils.java | 7 +-- .../dubbo/config/spring/util/PropertySourcesUtilsTest.java | 9 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/util/PropertySourcesUtils.java b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/util/PropertySourcesUtils.java index 5b183e1..c9a4d12 100644 --- a/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/util/PropertySourcesUtils.java +++ b/dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/util/PropertySourcesUtils.java @@ -19,6 +19,7 @@ package com.alibaba.dubbo.config.spring.util; import org.springframework.core.env.EnumerablePropertySource; import org.springframework.core.env.PropertySource; import org.springframework.core.env.PropertySources; +import org.springframework.core.env.PropertySourcesPropertyResolver; import java.util.LinkedHashMap; import java.util.Map; @@ -46,13 +47,15 @@ public abstract class PropertySourcesUtils { String normalizedPrefix = normalizePrefix(prefix); +PropertySourcesPropertyResolver propertyResolver = new PropertySourcesPropertyResolver((PropertySources) propertySources); + for (PropertySource source : propertySources) { if (source instanceof EnumerablePropertySource) { for (String name : ((EnumerablePropertySource) source).getPropertyNames()) { if (name.startsWith(normalizedPrefix)) { String subName = name.substring(normalizedPrefix.length()); -Object value = source.getProperty(name); -subProperties.put(subName, String.valueOf(value)); +String value = propertyResolver.getProperty(name); +subProperties.put(subName, value); } } } diff --git a/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/util/PropertySourcesUtilsTest.java b/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/util/PropertySourcesUtilsTest.java index 5dd526f..2840ecf 100644 --- a/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/util/PropertySourcesUtilsTest.java +++ b/dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/util/PropertySourcesUtilsTest.java @@ -69,6 +69,15 @@ public class PropertySourcesUtilsTest { Assert.assertEquals(Collections.emptyMap(), result); +source.put(KEY_PREFIX + ".app.name", "${info.name}"); +source.put("info.name", "Hello app"); + +result = PropertySourcesUtils.getSubProperties(propertySources, KEY_PREFIX); + +String appName = result.get("app.name"); + +Assert.assertEquals("Hello app", appName); + } } -- To stop receiving notification emails like this one, please contact mercybl...@apache.org.
[incubator-dubbo] branch master updated: fixed start.sh #1879 (#1900)
This is an automated email from the ASF dual-hosted git repository. wangxin pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git The following commit(s) were added to refs/heads/master by this push: new 5916e8b fixed start.sh #1879 (#1900) 5916e8b is described below commit 5916e8b1e853c74ed9d2b832f170756b35f478fb Author: AfeiJavaer <404961...@qq.com> AuthorDate: Thu Jun 7 19:30:58 2018 +0800 fixed start.sh #1879 (#1900) --- .../src/main/resources/META-INF/assembly/bin/start.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/start.sh b/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/start.sh index 3b491f0..4cddcd0 100755 --- a/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/start.sh +++ b/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/start.sh @@ -79,7 +79,7 @@ while [ $COUNT -lt 1 ]; do COUNT=`netstat -an | grep $SERVER_PORT | wc -l` fi else - COUNT=`ps -f | grep java | grep -v grep | grep "$DEPLOY_DIR" | awk '{print $2}' | wc -l` + COUNT=`ps -ef | grep java | grep -v grep | grep "$DEPLOY_DIR" | awk '{print $2}' | wc -l` fi if [ $COUNT -gt 0 ]; then break @@ -87,6 +87,6 @@ while [ $COUNT -lt 1 ]; do done echo "OK!" -PIDS=`ps -f | grep java | grep -v grep | grep "$DEPLOY_DIR" | awk '{print $2}'` +PIDS=`ps -ef | grep java | grep -v grep | grep "$DEPLOY_DIR" | awk '{print $2}'` echo "PID: $PIDS" echo "STDOUT: $STDOUT_FILE" -- To stop receiving notification emails like this one, please contact wang...@apache.org.
[incubator-dubbo] branch master updated: Enchance test coverage of dubbo cluster module (#1885)
This is an automated email from the ASF dual-hosted git repository. wangxin pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git The following commit(s) were added to refs/heads/master by this push: new 282 Enchance test coverage of dubbo cluster module (#1885) 282 is described below commit 2828d38424bf936e21d16e6f32c8750685b7 Author: Xin Wang AuthorDate: Thu Jun 7 19:06:41 2018 +0800 Enchance test coverage of dubbo cluster module (#1885) * 修改测试 * modify test case of dubbo-cluster * update test * #1679 Enhance the test coverage part-1 : dubbo-cluster module * add asf header * add setup * add setup * add test case * fix test case * add ignore --- .../cluster/configurator/AbstractConfigurator.java | 4 - .../loadbalance/ConsistentHashLoadBalance.java | 1 + .../absent/AbsentConfiguratorTest.java | 27 +-- .../cluster/configurator/consts/UrlConstant.java | 31 +++ .../override/OverrideConfiguratorTest.java | 20 +- .../rpc/cluster/directory/MockDirInvocation.java | 66 ++ .../rpc/cluster/directory/StaticDirectoryTest.java | 65 ++ .../loadbalance/ConsistentHashLoadBalanceTest.java | 30 +-- .../loadbalance/LeastActiveBalanceTest.java| 42 .../cluster/loadbalance/LoadBalanceBaseTest.java | 148 .../rpc/cluster/loadbalance/LoadBalanceTest.java | 204 .../cluster/loadbalance/RandomLoadBalanceTest.java | 57 + .../loadbalance/RoundRobinLoadBalanceTest.java | 29 +-- .../dubbo/rpc/cluster/merger/ResultMergerTest.java | 257 + .../router/condition/ConditionRouterTest.java | 132 +-- .../cluster/router/file/FileRouterEngineTest.java | 2 +- .../cluster/router/script/ScriptRouterTest.java| 20 +- .../support/AbstractClusterInvokerTest.java| 2 +- .../support/FailSafeClusterInvokerTest.java| 2 +- .../support/FailbackClusterInvokerTest.java| 2 +- .../support/FailfastClusterInvokerTest.java| 2 +- .../cluster/support/ForkingClusterInvokerTest.java | 2 +- .../support/wrapper/MockClusterInvokerTest.java| 2 +- .../extensionloader/ExtensionLoaderTest.java | 2 +- .../ExtensionLoader_Adaptive_Test.java | 2 +- .../ext6_inject/impl/Ext6Impl1.java| 2 +- .../com/alibaba/dubbo/common/json/JSONTest.java| 2 +- .../alibaba/dubbo/config/ReferenceConfigTest.java | 2 +- .../com/alibaba/dubbo/config/url/UrlTestBase.java | 2 +- .../alibaba/dubbo/config/spring/ConfigTest.java| 2 +- .../support/AbstractRegistryFactoryTest.java | 2 +- .../remoting/buffer/DirectChannelBufferTest.java | 2 +- .../remoting/buffer/HeapChannelBufferTest.java | 2 +- .../dubbo/remoting/codec/ExchangeCodecTest.java| 2 +- .../dubbo/remoting/codec/TelnetCodecTest.java | 2 +- .../handler/ConnectChannelHandlerTest.java | 2 +- .../handler/WrappedChannelHandlerTest.java | 2 +- .../transport/mina/ClientToServerTest.java | 2 +- .../support/header/HeartbeatHandlerTest.java | 2 +- .../transport/netty/ClientToServerTest.java| 2 +- .../protocol/dubbo/DubboInvokerAvilableTest.java | 2 +- .../rpc/protocol/dubbo/DubboProtocolTest.java | 4 +- .../rpc/protocol/dubbo/ImplicitCallBackTest.java | 2 +- .../rpc/protocol/injvm/InjvmProtocolTest.java | 4 +- .../dubbo/rpc/protocol/rmi/RmiProtocolTest.java| 2 +- .../dubbo/examples/validation/ValidationTest.java | 2 +- 46 files changed, 784 insertions(+), 413 deletions(-) diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/configurator/AbstractConfigurator.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/configurator/AbstractConfigurator.java index a213375..42b688b 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/configurator/AbstractConfigurator.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/configurator/AbstractConfigurator.java @@ -40,10 +40,6 @@ public abstract class AbstractConfigurator implements Configurator { this.configuratorUrl = url; } -public static void main(String[] args) { -System.out.println(URL.encode("timeout=100")); -} - @Override public URL getUrl() { return configuratorUrl; diff --git a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java index 595cec9..d65113b 100644 --- a/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java +++ b/dubbo-cluster/src/main/java/com/alibaba/dubbo/rpc/cluster/loadbalance/ConsistentHashLoadBalance.java @@ -36,6
[incubator-dubbo] branch master updated: unit test for ReflectUtils (#1898)
This is an automated email from the ASF dual-hosted git repository. iluo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git The following commit(s) were added to refs/heads/master by this push: new 58dab96 unit test for ReflectUtils (#1898) 58dab96 is described below commit 58dab96da4430efd54e6c563011eb6a9b2dbb861 Author: Ian Luo AuthorDate: Thu Jun 7 17:20:42 2018 +0800 unit test for ReflectUtils (#1898) * #1682: Enhance the test coverage part-4 : dubbo-common/src/main/java/com/alibaba/dubbo/common/status(store|threadpoolutils) modules * fix test failures --- .../alibaba/dubbo/common/utils/ReflectUtils.java | 25 +- .../dubbo/common/utils/ReflectUtilsTest.java | 313 +++-- 2 files changed, 301 insertions(+), 37 deletions(-) diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/ReflectUtils.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/ReflectUtils.java index f9a8bba..38c4a0d 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/ReflectUtils.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/ReflectUtils.java @@ -166,30 +166,15 @@ public final class ReflectUtils { */ public static boolean isCompatible(Class c, Object o) { boolean pt = c.isPrimitive(); -if (o == null) +if (o == null) { return !pt; +} if (pt) { -if (c == int.class) -c = Integer.class; -else if (c == boolean.class) -c = Boolean.class; -else if (c == long.class) -c = Long.class; -else if (c == float.class) -c = Float.class; -else if (c == double.class) -c = Double.class; -else if (c == char.class) -c = Character.class; -else if (c == byte.class) -c = Byte.class; -else if (c == short.class) -c = Short.class; +c = getBoxedClass(c); } -if (c == o.getClass()) -return true; -return c.isInstance(o); + +return c == o.getClass() || c.isInstance(o); } /** diff --git a/dubbo-common/src/test/java/com/alibaba/dubbo/common/utils/ReflectUtilsTest.java b/dubbo-common/src/test/java/com/alibaba/dubbo/common/utils/ReflectUtilsTest.java index 1852797..88daeb3 100644 --- a/dubbo-common/src/test/java/com/alibaba/dubbo/common/utils/ReflectUtilsTest.java +++ b/dubbo-common/src/test/java/com/alibaba/dubbo/common/utils/ReflectUtilsTest.java @@ -16,29 +16,87 @@ */ package com.alibaba.dubbo.common.utils; -import junit.framework.TestCase; import org.junit.Test; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; +import java.util.Date; import java.util.List; import java.util.Map; import java.util.Set; +import static junit.framework.TestCase.assertEquals; +import static junit.framework.TestCase.assertNotNull; +import static junit.framework.TestCase.assertNull; +import static junit.framework.TestCase.assertTrue; +import static junit.framework.TestCase.fail; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.hasKey; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.sameInstance; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThat; -import static org.junit.matchers.JUnitMatchers.containsString; -public class ReflectUtilsTest extends TestCase { +public class ReflectUtilsTest { +@Test +public void testIsPrimitives() throws Exception { +assertTrue(ReflectUtils.isPrimitives(boolean[].class)); +assertTrue(ReflectUtils.isPrimitives(byte.class)); +assertFalse(ReflectUtils.isPrimitive(Map[].class)); +} + +@Test +public void testIsPrimitive() throws Exception { +assertTrue(ReflectUtils.isPrimitive(boolean.class)); +assertTrue(ReflectUtils.isPrimitive(String.class)); +assertTrue(ReflectUtils.isPrimitive(Boolean.class)); +assertTrue(ReflectUtils.isPrimitive(Character.class)); +assertTrue(ReflectUtils.isPrimitive(Number.class)); +assertTrue(ReflectUtils.isPrimitive(Date.class)); +assertFalse(ReflectUtils.isPrimitive(Map.class)); +} + +@Test +public void testGetBoxedClass() throws Exception { +assertThat(ReflectUtils.getBoxedClass(int.class), sameInstance(Integer.class)); +assertThat(ReflectUtils.getBoxedClass(boolean.class), sameInstance(Boolean.class)); +assertThat(ReflectUtils.getBoxedClass(long.class), sameInstance(Long.class)); +assertThat(ReflectUtils.getBoxedClass(float.class), sameInstance(Float.class)); +