[incubator-dubbo] branch 2.6.x updated: [DUBBO-2489] MockClusterInvoker provides local forced mock,I tested it locally, but it doesn't work (#2739)

2018-11-06 Thread liujun
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch 2.6.x
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git


The following commit(s) were added to refs/heads/2.6.x by this push:
 new 5da01b1  [DUBBO-2489] MockClusterInvoker provides local forced mock,I 
tested it locally, but it doesn't work (#2739)
5da01b1 is described below

commit 5da01b1d278bc723152e0ef7139b1b1fdab562f8
Author: Ian Luo 
AuthorDate: Wed Nov 7 14:24:53 2018 +0800

[DUBBO-2489] MockClusterInvoker provides local forced mock,I tested it 
locally, but it doesn't work (#2739)
---
 .../com/alibaba/dubbo/config/AbstractConfig.java   |   2 +-
 .../dubbo/config/AbstractInterfaceConfig.java  |  53 
 .../alibaba/dubbo/config/AbstractMethodConfig.java |  10 +-
 .../com/alibaba/dubbo/config/ReferenceConfig.java  |   3 +-
 .../com/alibaba/dubbo/config/ServiceConfig.java|   3 +-
 .../alibaba/dubbo/config/AbstractConfigTest.java   |   3 +-
 .../dubbo/config/AbstractInterfaceConfigTest.java  |  27 ++--
 .../com/alibaba/dubbo/rpc/support/MockInvoker.java | 144 +
 8 files changed, 151 insertions(+), 94 deletions(-)

diff --git 
a/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractConfig.java
 
b/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractConfig.java
index 782215d..548205e 100644
--- 
a/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractConfig.java
+++ 
b/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractConfig.java
@@ -56,7 +56,7 @@ public abstract class AbstractConfig implements Serializable {
 
 private static final Pattern PATTERN_PATH = 
Pattern.compile("[/\\-$._0-9a-zA-Z]+");
 
-private static final Pattern PATTERN_NAME_HAS_SYMBOL = 
Pattern.compile("[:*,/\\-._0-9a-zA-Z]+");
+private static final Pattern PATTERN_NAME_HAS_SYMBOL = 
Pattern.compile("[:*,\\s/\\-._0-9a-zA-Z]+");
 
 private static final Pattern PATTERN_KEY = 
Pattern.compile("[*,\\-._0-9a-zA-Z]+");
 private static final Map legacyProperties = new 
HashMap();
diff --git 
a/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractInterfaceConfig.java
 
b/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractInterfaceConfig.java
index 87b50eb..4eec460 100644
--- 
a/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractInterfaceConfig.java
+++ 
b/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractInterfaceConfig.java
@@ -288,7 +288,36 @@ public abstract class AbstractInterfaceConfig extends 
AbstractMethodConfig {
 }
 }
 
-protected void checkStubAndMock(Class interfaceClass) {
+void checkMock(Class interfaceClass) {
+if (ConfigUtils.isEmpty(mock)) {
+return;
+}
+
+String normalizedMock = MockInvoker.normalizeMock(mock);
+if (normalizedMock.startsWith(Constants.RETURN_PREFIX)) {
+normalizedMock = 
normalizedMock.substring(Constants.RETURN_PREFIX.length()).trim();
+try {
+MockInvoker.parseMockValue(normalizedMock);
+} catch (Exception e) {
+throw new IllegalStateException("Illegal mock return in 
");
+}
+} else if (normalizedMock.startsWith(Constants.THROW_PREFIX)) {
+normalizedMock = 
normalizedMock.substring(Constants.THROW_PREFIX.length()).trim();
+if (ConfigUtils.isNotEmpty(normalizedMock)) {
+try {
+MockInvoker.getThrowable(normalizedMock);
+} catch (Exception e) {
+throw new IllegalStateException("Illegal mock throw in 
");
+}
+}
+} else {
+MockInvoker.getMockObject(normalizedMock, interfaceClass);
+}
+}
+
+void checkStub(Class interfaceClass) {
 if (ConfigUtils.isNotEmpty(local)) {
 Class localClass = ConfigUtils.isDefault(local) ? 
ReflectUtils.forName(interfaceClass.getName() + "Local") : 
ReflectUtils.forName(local);
 if (!interfaceClass.isAssignableFrom(localClass)) {
@@ -311,26 +340,6 @@ public abstract class AbstractInterfaceConfig extends 
AbstractMethodConfig {
 throw new IllegalStateException("No such constructor \"public 
" + localClass.getSimpleName() + "(" + interfaceClass.getName() + ")\" in local 
implementation class " + localClass.getName());
 }
 }
-if (ConfigUtils.isNotEmpty(mock)) {
-if (mock.startsWith(Constants.RETURN_PREFIX)) {
-String value = 
mock.substring(Constants.RETURN_PREFIX.length());
-try {
-MockInvoker.parseMockValue(value);
-} catch (Exception e) {
-throw new IllegalStateException("Illegal mock json value 
in ");
-}
-  

[incubator-dubbo] branch master updated: [DUBBO-2489] MockClusterInvoker provides local forced mock,I tested it locally, but it doesn't work (#2742)

2018-11-06 Thread liujun
This is an automated email from the ASF dual-hosted git repository.

liujun 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 e3bd693  [DUBBO-2489] MockClusterInvoker provides local forced mock,I 
tested it locally, but it doesn't work (#2742)
e3bd693 is described below

commit e3bd69375da34e97b8801c96e654ee507fa15dce
Author: Ian Luo 
AuthorDate: Wed Nov 7 14:21:42 2018 +0800

[DUBBO-2489] MockClusterInvoker provides local forced mock,I tested it 
locally, but it doesn't work (#2742)
---
 .../org/apache/dubbo/config/AbstractConfig.java|   2 +-
 .../dubbo/config/AbstractInterfaceConfig.java  |  53 
 .../apache/dubbo/config/AbstractMethodConfig.java  |  10 +-
 .../org/apache/dubbo/config/ReferenceConfig.java   |   3 +-
 .../org/apache/dubbo/config/ServiceConfig.java |   3 +-
 .../apache/dubbo/config/AbstractConfigTest.java|   3 +-
 .../dubbo/config/AbstractInterfaceConfigTest.java  |  27 ++--
 .../org/apache/dubbo/rpc/support/MockInvoker.java  | 144 +
 8 files changed, 151 insertions(+), 94 deletions(-)

diff --git 
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractConfig.java
 
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractConfig.java
index fdaa3b1..b1aeeed 100644
--- 
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractConfig.java
+++ 
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractConfig.java
@@ -57,7 +57,7 @@ public abstract class AbstractConfig implements Serializable {
 
 private static final Pattern PATTERN_PATH = 
Pattern.compile("[/\\-$._0-9a-zA-Z]+");
 
-private static final Pattern PATTERN_NAME_HAS_SYMBOL = 
Pattern.compile("[:*,/\\-._0-9a-zA-Z]+");
+private static final Pattern PATTERN_NAME_HAS_SYMBOL = 
Pattern.compile("[:*,\\s/\\-._0-9a-zA-Z]+");
 
 private static final Pattern PATTERN_KEY = 
Pattern.compile("[*,\\-._0-9a-zA-Z]+");
 private static final Map legacyProperties = new 
HashMap();
diff --git 
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java
 
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java
index 70ab62e..3ff1ceb 100644
--- 
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java
+++ 
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java
@@ -286,7 +286,36 @@ public abstract class AbstractInterfaceConfig extends 
AbstractMethodConfig {
 }
 }
 
-protected void checkStubAndMock(Class interfaceClass) {
+void checkMock(Class interfaceClass) {
+if (ConfigUtils.isEmpty(mock)) {
+return;
+}
+
+String normalizedMock = MockInvoker.normalizeMock(mock);
+if (normalizedMock.startsWith(Constants.RETURN_PREFIX)) {
+normalizedMock = 
normalizedMock.substring(Constants.RETURN_PREFIX.length()).trim();
+try {
+MockInvoker.parseMockValue(normalizedMock);
+} catch (Exception e) {
+throw new IllegalStateException("Illegal mock return in 
");
+}
+} else if (normalizedMock.startsWith(Constants.THROW_PREFIX)) {
+normalizedMock = 
normalizedMock.substring(Constants.THROW_PREFIX.length()).trim();
+if (ConfigUtils.isNotEmpty(normalizedMock)) {
+try {
+MockInvoker.getThrowable(normalizedMock);
+} catch (Exception e) {
+throw new IllegalStateException("Illegal mock throw in 
");
+}
+}
+} else {
+MockInvoker.getMockObject(normalizedMock, interfaceClass);
+}
+}
+
+void checkStub(Class interfaceClass) {
 if (ConfigUtils.isNotEmpty(local)) {
 Class localClass = ConfigUtils.isDefault(local) ? 
ReflectUtils.forName(interfaceClass.getName() + "Local") : 
ReflectUtils.forName(local);
 if (!interfaceClass.isAssignableFrom(localClass)) {
@@ -309,26 +338,6 @@ public abstract class AbstractInterfaceConfig extends 
AbstractMethodConfig {
 throw new IllegalStateException("No such constructor \"public 
" + localClass.getSimpleName() + "(" + interfaceClass.getName() + ")\" in local 
implementation class " + localClass.getName());
 }
 }
-if (ConfigUtils.isNotEmpty(mock)) {
-if (mock.startsWith(Constants.RETURN_PREFIX)) {
-String value = 
mock.substring(Constants.RETURN_PREFIX.length());
-try {
-MockInvoker.parseMockValue(value);
-} catch (Exception e) {
-throw new IllegalStateException("Illegal mock json value 
in ");
-}
-} 

[incubator-dubbo] branch master updated: fix typo (#2747)

2018-11-06 Thread wangxin
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 1a88c22  fix typo (#2747)
1a88c22 is described below

commit 1a88c22574cbb621bae5edadb2f2abd1cd9784d6
Author: yì jí 
AuthorDate: Wed Nov 7 14:16:55 2018 +0800

fix typo (#2747)
---
 .../org/apache/dubbo/remoting/transport/netty4/NettyServerHandler.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyServerHandler.java
 
b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyServerHandler.java
index ba30062..56d4ff6 100644
--- 
a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyServerHandler.java
+++ 
b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyServerHandler.java
@@ -30,7 +30,7 @@ import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
 /**
- * NettyClientHandler
+ * NettyServerHandler
  */
 @io.netty.channel.ChannelHandler.Sharable
 public class NettyServerHandler extends ChannelDuplexHandler {



[incubator-dubbo] 02/03: Make ReferenceBean depend on ConfigCenterBean, so that ConfigCenterBean can always be initialized before refer.

2018-11-06 Thread liujun
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch dev-metadata
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git

commit 22599b9e9b00997ecdc06ad7719e8fa054944a93
Author: ken.lj 
AuthorDate: Wed Nov 7 10:04:08 2018 +0800

Make ReferenceBean depend on ConfigCenterBean, so that ConfigCenterBean can 
always be initialized before refer.
---
 .../apache/dubbo/config/ConfigCenterConfig.java| 37 +-
 .../dubbo/config/spring/ConfigCenterBean.java  | 35 +++-
 .../apache/dubbo/config/spring/ReferenceBean.java  |  4 +++
 3 files changed, 74 insertions(+), 2 deletions(-)

diff --git 
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ConfigCenterConfig.java
 
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ConfigCenterConfig.java
index d454caf..50b7699 100644
--- 
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ConfigCenterConfig.java
+++ 
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ConfigCenterConfig.java
@@ -49,6 +49,9 @@ public class ConfigCenterConfig extends AbstractConfig {
 
 private String appname;
 private String configfile = "dubbo.properties";
+private String localconfigfile;
+
+private ApplicationConfig application;
 
 // customized parameters
 private Map parameters;
@@ -86,7 +89,11 @@ public class ConfigCenterConfig extends AbstractConfig {
 
Environment.getInstance().setDynamicConfiguration(dynamicConfiguration);
 String configContent = dynamicConfiguration.getConfig(configfile, 
group);
 
-String appConfigContent = dynamicConfiguration.getConfig(configfile, 
appname);
+String appConfigContent = dynamicConfiguration.getConfig
+(
+StringUtils.isNotEmpty(localconfigfile) ? 
localconfigfile : configfile,
+getApplicationName()
+);
 try {
 Environment.getInstance().setConfigCenterFirst(priority);
 
Environment.getInstance().updateExternalConfigurationMap(parseProperties(configContent));
@@ -96,6 +103,17 @@ public class ConfigCenterConfig extends AbstractConfig {
 }
 }
 
+private String getApplicationName() {
+if (application != null) {
+if (!application.isValid()) {
+throw new IllegalStateException(
+"No application config found or it's not a valid 
config! Please add  to your spring config.");
+}
+return application.getName();
+}
+return appname;
+}
+
 private Map parseProperties(String content) throws 
IOException {
 Map map = new HashMap<>();
 if (content == null) {
@@ -216,6 +234,15 @@ public class ConfigCenterConfig extends AbstractConfig {
 this.configfile = configfile;
 }
 
+@Parameter(excluded = true)
+public String getLocalconfigfile() {
+return localconfigfile;
+}
+
+public void setLocalconfigfile(String localconfigfile) {
+this.localconfigfile = localconfigfile;
+}
+
 @Parameter(key = Constants.CONFIG_APPNAME_KEY)
 public String getAppname() {
 return appname;
@@ -233,4 +260,12 @@ public class ConfigCenterConfig extends AbstractConfig {
 checkParameterName(parameters);
 this.parameters = parameters;
 }
+
+public ApplicationConfig getApplication() {
+return application;
+}
+
+public void setApplication(ApplicationConfig application) {
+this.application = application;
+}
 }
diff --git 
a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/ConfigCenterBean.java
 
b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/ConfigCenterBean.java
index b8754a2..aa88eaf 100644
--- 
a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/ConfigCenterBean.java
+++ 
b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/ConfigCenterBean.java
@@ -16,9 +16,16 @@
  */
 package org.apache.dubbo.config.spring;
 
+import org.apache.dubbo.config.ApplicationConfig;
 import org.apache.dubbo.config.ConfigCenterConfig;
+import org.apache.dubbo.config.spring.extension.SpringExtensionFactory;
+import org.springframework.beans.factory.BeanFactoryUtils;
 import org.springframework.beans.factory.DisposableBean;
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+import java.util.Map;
 
 /**
  * Since 2.7.0+, export and refer will only be executed when Spring is fully 
initialized, and each Config bean will get refreshed on the start of the export 
and refer process.
@@ -26,10 +33,36 @@ import org.springframework.beans.factory.InitializingBean;
  *
  * If use ConfigCenterConfig 

[incubator-dubbo] 01/03: cherry-pick 4d0a36c435ca59bfcf909c0e76fa2ab024fb7408 from master 重构 ServiceBean 的 isDelay 方法,使其更符合语义

2018-11-06 Thread liujun
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch dev-metadata
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git

commit 220c9da452acb0ae9aebc965bc00718989dad3fd
Author: 田小波 
AuthorDate: Tue Oct 30 17:12:38 2018 +0800

cherry-pick 4d0a36c435ca59bfcf909c0e76fa2ab024fb7408 from master
重构 ServiceBean 的 isDelay 方法,使其更符合语义
---
 .../java/org/apache/dubbo/config/spring/ServiceBean.java| 13 ++---
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git 
a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/ServiceBean.java
 
b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/ServiceBean.java
index b644d62..e6bc114 100644
--- 
a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/ServiceBean.java
+++ 
b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/ServiceBean.java
@@ -108,7 +108,7 @@ public class ServiceBean extends ServiceConfig 
implements InitializingBean
 
 @Override
 public void onApplicationEvent(ContextRefreshedEvent event) {
-if (isDelay() && !isExported() && !isUnexported()) {
+if (!isExported() && !isUnexported()) {
 if (logger.isInfoEnabled()) {
 logger.info("The service ready on spring started. service: " + 
getInterface());
 }
@@ -116,15 +116,6 @@ public class ServiceBean extends ServiceConfig 
implements InitializingBean
 }
 }
 
-private boolean isDelay() {
-Integer delay = getDelay();
-ProviderConfig provider = getProvider();
-if (delay == null && provider != null) {
-delay = provider.getDelay();
-}
-return supportedApplicationListener && (delay == null || delay == -1);
-}
-
 @Override
 @SuppressWarnings({"unchecked", "deprecation"})
 public void afterPropertiesSet() throws Exception {
@@ -264,7 +255,7 @@ public class ServiceBean extends ServiceConfig 
implements InitializingBean
 
 checkAndUpdateSubConfigs();
 
-if (!isDelay()) {
+if (!supportedApplicationListener) {
 export();
 }
 }



[incubator-dubbo] branch dev-metadata updated (072b51e -> d85550a)

2018-11-06 Thread liujun
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a change to branch dev-metadata
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git.


from 072b51e  Merge pull request #2744, metadata unit test and generic 
test, refactor zk store.
 new 220c9da  cherry-pick 4d0a36c435ca59bfcf909c0e76fa2ab024fb7408 from 
master 重构 ServiceBean 的 isDelay 方法,使其更符合语义
 new 22599b9  Make ReferenceBean depend on ConfigCenterBean, so that 
ConfigCenterBean can always be initialized before refer.
 new d85550a  Merge branch 'dev-metadata' of 
https://github.com/apache/incubator-dubbo into dev-metadata

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/dubbo/config/ConfigCenterConfig.java| 37 +-
 .../dubbo/config/spring/ConfigCenterBean.java  | 35 +++-
 .../apache/dubbo/config/spring/ReferenceBean.java  |  4 +++
 .../apache/dubbo/config/spring/ServiceBean.java| 13 ++--
 4 files changed, 76 insertions(+), 13 deletions(-)



[incubator-dubbo] 03/03: Merge branch 'dev-metadata' of https://github.com/apache/incubator-dubbo into dev-metadata

2018-11-06 Thread liujun
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch dev-metadata
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git

commit d85550a5fdba7c75e666e5395454d93a0c82335e
Merge: 22599b9 072b51e
Author: ken.lj 
AuthorDate: Wed Nov 7 10:05:13 2018 +0800

Merge branch 'dev-metadata' of https://github.com/apache/incubator-dubbo 
into dev-metadata

 dubbo-compatible/pom.xml   |   7 +-
 .../apache/dubbo/generic/GenericServiceTest.java   | 181 -
 .../org/apache/dubbo/service/ComplexObject.java| 282 +
 .../java/org/apache/dubbo/service/DemoService.java |   8 +-
 .../org/apache/dubbo/service/DemoServiceImpl.java  |  15 +-
 .../dubbo/config/AbstractInterfaceConfig.java  |   2 +-
 .../META-INF/spring/dubbo-demo-consumer.xml|   3 +-
 .../META-INF/spring/dubbo-demo-provider.xml|   2 +-
 .../definition/builder/CollectionTypeBuilder.java  |   3 +-
 .../definition/model/FullServiceDefinition.java|   8 +
 .../definition/model/MethodDefinition.java |  18 ++
 .../definition/model/ServiceDefinition.java|  16 ++
 .../metadata/definition/model/TypeDefinition.java  |  18 ++
 .../dubbo/metadata/definition/util/ClassUtils.java |   4 +-
 .../definition/ServiceDefinitionBuildderTest.java  |  81 ++
 .../common/ResultWithRawCollections.java   |   2 +-
 .../metadata/definition/service/ComplexObject.java | 280 
 .../metadata/definition/service/DemoService.java}  |  18 +-
 .../dubbo-metadata-report-api/pom.xml  |   9 +-
 .../identifier/ConsumerMetadataIdentifier.java |   4 +-
 .../metadata/identifier/MetadataIdentifier.java|   5 +-
 .../identifier/ProviderMetadataIdentifier.java |   2 +-
 .../integration/MetadataReportService.java |   1 +
 .../dubbo/metadata/metadata/MethodDescriptor.java  |  54 
 .../dubbo/metadata/metadata/ServiceDescriptor.java |  55 
 .../dubbo/metadata/metadata/TypeDescriptor.java|  65 -
 .../metadata/builder/ArrayTypeBuilder.java |  36 ---
 .../metadata/builder/CollectionTypeBuilder.java|  59 -
 .../metadata/builder/DefaultTypeBuilder.java   | 113 -
 .../metadata/metadata/builder/EnumTypeBuilder.java |  45 
 .../metadata/metadata/builder/MapTypeBuilder.java  |  60 -
 .../metadata/builder/ServiceDescriptorBuilder.java |  71 --
 .../metadata/metadata/builder/TypeBuilder.java |  23 --
 .../metadata/builder/TypeDescriptorBuilder.java|  63 -
 .../metadata/support/AbstractMetadataReport.java   |  13 +-
 .../metadata/integration/RetryTestService.java |   2 +-
 .../metadata/builder/ArrayTypeBuilderTest.java |  89 ---
 .../builder/CollectionTypeBuilderTest.java |  90 ---
 .../metadata/metadata/builder/ComplexEnum.java |  16 --
 .../metadata/metadata/builder/ComplexObject.java   |  37 ---
 .../metadata/builder/DefaultTypeBuilderTest.java   |  64 -
 .../metadata/builder/EnumTypeBuilderTest.java  |  84 --
 .../metadata/builder/MapTypeBuilderTest.java   |  89 ---
 .../builder/ServiceDescriptorBuilderTest.java  |  25 --
 .../metadata/metadata/builder/SingleEnum.java  |   8 -
 .../metadata/metadata/builder/TestService.java |  45 
 .../builder/TypeDescriptorBuilderTest.java | 101 
 .../store/test/JTestMetadataReport4Test.java   |   3 +-
 .../support/AbstractMetadataReportFactoryTest.java |   1 -
 .../support/AbstractMetadataReportTest.java|  11 +-
 .../store/zookeeper/ZookeeperMetadataReport.java   |  10 +-
 .../zookeeper/ZookeeperMetadataReportTest.java |  32 +--
 .../java/org/apache/dubbo/registry/ZKTools.java|   4 +-
 .../dubbo/remoting/zookeeper/ZookeeperClient.java  |   4 +
 .../zookeeper/curator/CuratorZookeeperClient.java  |  40 +++
 .../zookeeper/support/AbstractZookeeperClient.java |  28 ++
 .../zookeeper/zkclient/ZkClientWrapper.java|  15 ++
 .../zkclient/ZkclientZookeeperClient.java  |  25 ++
 .../curator/CuratorZookeeperClientTest.java|  30 ++-
 .../zkclient/ZkclientZookeeperClientTest.java  |  30 ++-
 .../webservice/WebserviceProtocolTest.java |   4 +-
 61 files changed, 1144 insertions(+), 1369 deletions(-)



[incubator-dubbo] branch dev-metadata updated: Merge pull request #2744, metadata unit test and generic test, refactor zk store.

2018-11-06 Thread liujun
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch dev-metadata
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git


The following commit(s) were added to refs/heads/dev-metadata by this push:
 new 072b51e  Merge pull request #2744, metadata unit test and generic 
test, refactor zk store.
072b51e is described below

commit 072b51e0bafc0443731de0767867ac3d5f9498e8
Author: cvictory 
AuthorDate: Tue Nov 6 17:19:53 2018 +0800

Merge pull request #2744, metadata unit test and generic test, refactor zk 
store.
---
 dubbo-compatible/pom.xml   |   7 +-
 .../apache/dubbo/generic/GenericServiceTest.java   | 181 -
 .../org/apache/dubbo/service/ComplexObject.java| 282 +
 .../java/org/apache/dubbo/service/DemoService.java |   8 +-
 .../org/apache/dubbo/service/DemoServiceImpl.java  |  15 +-
 .../dubbo/config/AbstractInterfaceConfig.java  |   2 +-
 .../META-INF/spring/dubbo-demo-consumer.xml|   3 +-
 .../META-INF/spring/dubbo-demo-provider.xml|   2 +-
 .../definition/builder/CollectionTypeBuilder.java  |   3 +-
 .../definition/model/FullServiceDefinition.java|   8 +
 .../definition/model/MethodDefinition.java |  18 ++
 .../definition/model/ServiceDefinition.java|  16 ++
 .../metadata/definition/model/TypeDefinition.java  |  18 ++
 .../dubbo/metadata/definition/util/ClassUtils.java |   4 +-
 .../definition/ServiceDefinitionBuildderTest.java  |  81 ++
 .../common/ResultWithRawCollections.java   |   2 +-
 .../metadata/definition/service/ComplexObject.java | 280 
 .../metadata/definition/service/DemoService.java}  |  18 +-
 .../dubbo-metadata-report-api/pom.xml  |   9 +-
 .../identifier/ConsumerMetadataIdentifier.java |   4 +-
 .../metadata/identifier/MetadataIdentifier.java|   5 +-
 .../identifier/ProviderMetadataIdentifier.java |   2 +-
 .../integration/MetadataReportService.java |   1 +
 .../dubbo/metadata/metadata/MethodDescriptor.java  |  54 
 .../dubbo/metadata/metadata/ServiceDescriptor.java |  55 
 .../dubbo/metadata/metadata/TypeDescriptor.java|  65 -
 .../metadata/builder/ArrayTypeBuilder.java |  36 ---
 .../metadata/builder/CollectionTypeBuilder.java|  59 -
 .../metadata/builder/DefaultTypeBuilder.java   | 113 -
 .../metadata/metadata/builder/EnumTypeBuilder.java |  45 
 .../metadata/metadata/builder/MapTypeBuilder.java  |  60 -
 .../metadata/builder/ServiceDescriptorBuilder.java |  71 --
 .../metadata/metadata/builder/TypeBuilder.java |  23 --
 .../metadata/builder/TypeDescriptorBuilder.java|  63 -
 .../metadata/support/AbstractMetadataReport.java   |  13 +-
 .../metadata/integration/RetryTestService.java |   2 +-
 .../metadata/builder/ArrayTypeBuilderTest.java |  89 ---
 .../builder/CollectionTypeBuilderTest.java |  90 ---
 .../metadata/metadata/builder/ComplexEnum.java |  16 --
 .../metadata/metadata/builder/ComplexObject.java   |  37 ---
 .../metadata/builder/DefaultTypeBuilderTest.java   |  64 -
 .../metadata/builder/EnumTypeBuilderTest.java  |  84 --
 .../metadata/builder/MapTypeBuilderTest.java   |  89 ---
 .../builder/ServiceDescriptorBuilderTest.java  |  25 --
 .../metadata/metadata/builder/SingleEnum.java  |   8 -
 .../metadata/metadata/builder/TestService.java |  45 
 .../builder/TypeDescriptorBuilderTest.java | 101 
 .../store/test/JTestMetadataReport4Test.java   |   3 +-
 .../support/AbstractMetadataReportFactoryTest.java |   1 -
 .../support/AbstractMetadataReportTest.java|  11 +-
 .../store/zookeeper/ZookeeperMetadataReport.java   |  10 +-
 .../zookeeper/ZookeeperMetadataReportTest.java |  32 +--
 .../java/org/apache/dubbo/registry/ZKTools.java|   4 +-
 .../dubbo/remoting/zookeeper/ZookeeperClient.java  |   4 +
 .../zookeeper/curator/CuratorZookeeperClient.java  |  40 +++
 .../zookeeper/support/AbstractZookeeperClient.java |  28 ++
 .../zookeeper/zkclient/ZkClientWrapper.java|  15 ++
 .../zkclient/ZkclientZookeeperClient.java  |  25 ++
 .../curator/CuratorZookeeperClientTest.java|  30 ++-
 .../zkclient/ZkclientZookeeperClientTest.java  |  30 ++-
 .../webservice/WebserviceProtocolTest.java |   4 +-
 61 files changed, 1144 insertions(+), 1369 deletions(-)

diff --git a/dubbo-compatible/pom.xml b/dubbo-compatible/pom.xml
index 1da947f..95be710 100644
--- a/dubbo-compatible/pom.xml
+++ b/dubbo-compatible/pom.xml
@@ -79,5 +79,10 @@
 ${project.parent.version}
 test
 
+
+com.alibaba
+fastjson
+test
+
 
-
\ No newline at end of file
+
diff --git 
a/dubbo-compatible/src/test/java/org/apache/dubbo/generic/GenericServiceTest.java
 

[incubator-dubbo] branch master updated: Add 'forks' config into xml config (#2568)

2018-11-06 Thread iluo
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 56b2193  Add 'forks' config into xml config (#2568)
56b2193 is described below

commit 56b219316205a12b4ce95a82b10b527798df9e34
Author: 时无两丶 <442367...@qq.com>
AuthorDate: Tue Nov 6 17:16:21 2018 +0800

Add 'forks' config into xml config (#2568)

* Add forks into xml config.

* Add forks into xml config.

* Add forks into xml config.
---
 .../java/org/apache/dubbo/config/AbstractMethodConfig.java | 13 +
 .../org/apache/dubbo/config/AbstractMethodConfigTest.java  |  7 +++
 .../src/main/resources/META-INF/compat/dubbo.xsd   | 10 ++
 .../src/main/resources/META-INF/dubbo.xsd  | 10 ++
 .../java/org/apache/dubbo/config/spring/ConfigTest.java| 14 ++
 5 files changed, 54 insertions(+)

diff --git 
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractMethodConfig.java
 
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractMethodConfig.java
index a4acce8..a2c3de6 100644
--- 
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractMethodConfig.java
+++ 
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractMethodConfig.java
@@ -64,6 +64,19 @@ public abstract class AbstractMethodConfig extends 
AbstractConfig {
 // customized parameters
 protected Map parameters;
 
+/**
+ * forks for forking cluster
+ */
+protected Integer forks;
+
+public Integer getForks() {
+return forks;
+}
+
+public void setForks(Integer forks) {
+this.forks = forks;
+}
+
 public Integer getTimeout() {
 return timeout;
 }
diff --git 
a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractMethodConfigTest.java
 
b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractMethodConfigTest.java
index 41549e3..063a2e3 100644
--- 
a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractMethodConfigTest.java
+++ 
b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractMethodConfigTest.java
@@ -36,6 +36,13 @@ public class AbstractMethodConfigTest {
 }
 
 @Test
+public void testForks() throws Exception {
+MethodConfig methodConfig = new MethodConfig();
+methodConfig.setForks(10);
+assertThat(methodConfig.getForks(), equalTo(10));
+}
+
+@Test
 public void testRetries() throws Exception {
 MethodConfig methodConfig = new MethodConfig();
 methodConfig.setRetries(3);
diff --git 
a/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/compat/dubbo.xsd 
b/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/compat/dubbo.xsd
index 92d7bd2..902bae8 100644
--- 
a/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/compat/dubbo.xsd
+++ 
b/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/compat/dubbo.xsd
@@ -101,6 +101,11 @@
 
 
 
+
+
+
+
+
 
 
 
@@ -492,6 +497,11 @@
 
 
 
+
+
+
+
+
 
 
 
diff --git 
a/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/dubbo.xsd 
b/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/dubbo.xsd
index 88fe25f..9b21ba2 100644
--- a/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/dubbo.xsd
+++ b/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/dubbo.xsd
@@ -101,6 +101,11 @@
 
 
 
+
+
+
+
+
 
 
 
@@ -486,6 +491,11 @@
 
 
 
+
+
+
+
+
 
 
 
diff --git 
a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/ConfigTest.java
 
b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/ConfigTest.java
index ca9cc94..d36fedc 100644
--- 
a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/ConfigTest.java
+++ 
b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/ConfigTest.java
@@ -148,6 +148,20 @@ public class ConfigTest {
 }
 
 @Test
+public void testForks() {
+ReferenceConfig reference = new 

[incubator-dubbo-ops.wiki] branch master updated: Initial Home page

2018-11-06 Thread min
This is an automated email from the ASF dual-hosted git repository.

min pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-ops.wiki.git


The following commit(s) were added to refs/heads/master by this push:
 new 196230b  Initial Home page
196230b is described below

commit 196230bc84101712bca235dfc7ef4c83c20e918a
Author: min 
AuthorDate: Tue Nov 6 17:13:23 2018 +0800

Initial Home page
---
 Home.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Home.md b/Home.md
new file mode 100644
index 000..d3b7e74
--- /dev/null
+++ b/Home.md
@@ -0,0 +1 @@
+Welcome to the incubator-dubbo-ops wiki!



[incubator-dubbo] branch master updated: Simplify the code of StringUtils to make it more graceful. (#2740)

2018-11-06 Thread iluo
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 aed0102   Simplify the code of StringUtils to make it more graceful. 
(#2740)
aed0102 is described below

commit aed0102f0a5a1d5d795bbe4589562d4346f41e70
Author: 田小波 
AuthorDate: Tue Nov 6 17:09:00 2018 +0800

 Simplify the code of StringUtils to make it more graceful. (#2740)

* Simplify the code of StringUtils to make it more graceful.

* Add Apache license
---
 .../org/apache/dubbo/common/utils/ArrayUtils.java  |  47 
 .../org/apache/dubbo/common/utils/StringUtils.java | 118 +
 .../apache/dubbo/common/utils/ArrayUtilsTest.java  |  41 +++
 .../apache/dubbo/common/utils/StringUtilsTest.java |  30 +-
 4 files changed, 191 insertions(+), 45 deletions(-)

diff --git 
a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ArrayUtils.java 
b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ArrayUtils.java
new file mode 100644
index 000..a0b62bd
--- /dev/null
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ArrayUtils.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dubbo.common.utils;
+
+/**
+ * Contains some methods to check array.
+ */
+public final class ArrayUtils {
+
+private ArrayUtils() {
+}
+
+/**
+ * Checks if the array is null or empty. 
+ *
+ * @param array th array to check
+ * @return {@code true} if the array is null or empty.
+ */
+public static boolean isEmpty(final Object[] array) {
+return array == null || array.length == 0;
+}
+
+/**
+ * Checks if the array is not null or empty. 
+ *
+ * @param array th array to check
+ * @return {@code true} if the array is not null or empty.
+ */
+public static boolean isNotEmpty(final Object[] array) {
+return !isEmpty(array);
+}
+}
diff --git 
a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/StringUtils.java 
b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/StringUtils.java
index c2c708f..f599218 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/StringUtils.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/StringUtils.java
@@ -174,7 +174,7 @@ public final class StringUtils {
  *  {@code null} if null String input
  */
 public static String removeEnd(final String str, final String remove) {
-if (isEmpty(str) || isEmpty(remove)) {
+if (isAnyEmpty(str, remove)) {
 return str;
 }
 if (str.endsWith(remove)) {
@@ -314,7 +314,7 @@ public final class StringUtils {
  *  {@code null} if null String input
  */
 public static String replace(final String text, final String searchString, 
final String replacement, int max) {
-if (isEmpty(text) || isEmpty(searchString) || replacement == null || 
max == 0) {
+if (isAnyEmpty(text, searchString) || replacement == null || max == 0) 
{
 return text;
 }
 int start = 0;
@@ -340,10 +340,7 @@ public final class StringUtils {
 }
 
 public static boolean isBlank(String str) {
-if (str == null || str.length() == 0) {
-return true;
-}
-return false;
+return isEmpty(str);
 }
 
 /**
@@ -353,10 +350,57 @@ public final class StringUtils {
  * @return is empty.
  */
 public static boolean isEmpty(String str) {
-if (str == null || str.length() == 0) {
-return true;
+return str == null || str.isEmpty();
+}
+
+/**
+ * Checks if the strings contain empty or null elements. 
+ *
+ * 
+ * StringUtils.isNoneEmpty(null)= false
+ * StringUtils.isNoneEmpty("")  = false
+ * StringUtils.isNoneEmpty(" ") = true
+ * StringUtils.isNoneEmpty("abc")   = true
+ * StringUtils.isNoneEmpty("abc", "def")= true
+ * StringUtils.isNoneEmpty("abc", null) = false
+ * 

[incubator-dubbo] branch master updated (2284ede -> 16f7a1e)

2018-11-06 Thread iluo
This is an automated email from the ASF dual-hosted git repository.

iluo pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git.


from 2284ede  code format (#2730)
 add 16f7a1e  Close all servers/ports after tests finish (#2741)

No new revisions were added by this update.

Summary of changes:
 .../org/apache/dubbo/rpc/protocol/dubbo/DubboProtocolTest.java   | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)



[incubator-dubbo-website] 01/02: enhance doc to explain mock behavior futher

2018-11-06 Thread iluo
This is an automated email from the ASF dual-hosted git repository.

iluo pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-website.git

commit 5d305c1e21cb362761e382b02702e07d1e7adca0
Author: beiwei30 
AuthorDate: Tue Nov 6 16:43:51 2018 +0800

enhance doc to explain mock behavior futher
---
 docs/en-us/user/demos/local-mock.md | 53 +
 docs/zh-cn/user/demos/local-mock.md | 53 +
 2 files changed, 106 insertions(+)

diff --git a/docs/en-us/user/demos/local-mock.md 
b/docs/en-us/user/demos/local-mock.md
index 28ab66b..2a69417 100644
--- a/docs/en-us/user/demos/local-mock.md
+++ b/docs/en-us/user/demos/local-mock.md
@@ -43,5 +43,58 @@ Consider changing to Mock implementation and return null in 
Mock implementation.
 
 ```
 
+## Advanced Usage
+
+### return
+
+`return` can be used to return an object's string representation as the mocked 
return value. The legal values incude:
+* *empty*: empty value, default value for primary type, and empty value for 
collections.
+* *null*: `null`
+* *true*: `true`
+* *false*: `false`
+* *JSON format*: a mocked return value in JSON format, will be deserialized at 
runtime 
+
+### throw
+
+`throw` can be used to throw an exception object as the mocked return value. 
+
+Throw a default RPCException when invocation gets wrong:
+
+```xml
+
+```
+
+Throw a specified exception when invocation gets wrong:
+
+```xml
+
+```
+
+### force & fail
+
+Since `2.6.6` and above, it is possible to use `fail:` and `force:` in 
Spring's XML configuration to define mock behavior. `force:` means the mocked 
value is forced to use no matter the invocation gets wrong or not, in fact, the 
remote invocation will not happen at all. `fail:` is consistent with the 
default behavior, that is, mock happens only when invocation gets wrong. 
Futhermore, both `force:` and `fail:` can be used together with `throw` or 
`return` to define the mock behavior further.
+
+Force to return the specified value:
+
+```xml
+
+```
+
+Force to throw the specified exception:
+
+```xml
+
+```
+
+### Specify Mock For Particular Method Only
+
+Mock behavior can be specified on the method level. Assume there are a couple 
of methods on `com.foo.BarService`, we can specify the mock behavior for one 
particular method only, say `sayHello()`. In the example below, "fake" is 
forced to return everytime when `sayHello()` is called, but other methods will 
not be effected:
+
+```xml
+
+
+
+```
+
 [^1]: Mock is a subset of the Stub. If you use Stub, you may need to rely on 
the RpcException class. If you use Mock, you do not need to rely on 
RpcException, when throwing RpcException, it will callback Mock implementation 
class.
 [^2]: BarServiceMock implements BarService and has a no-argument constructor.
diff --git a/docs/zh-cn/user/demos/local-mock.md 
b/docs/zh-cn/user/demos/local-mock.md
index 1518b7a..7b627d7 100644
--- a/docs/zh-cn/user/demos/local-mock.md
+++ b/docs/zh-cn/user/demos/local-mock.md
@@ -43,5 +43,58 @@ try {
 
 ```
 
+## 进阶用法
+
+### return
+
+使用 `return` 来返回一个字符串表示的对象,作为 Mock 的返回值。合法的字符串可以是:
+* *empty*: 代表空,基本类型的默认值,或者集合类的空值
+* *null*: `null`
+* *true*: `true`
+* *false*: `false`
+* *JSON 格式*: 反序列化 JSON 所得到的对象
+
+### throw
+
+使用 `throw` 来返回一个 Exception 对象,作为 Mock 的返回值。
+
+当调用出错时,抛出一个默认的 RPCException:
+
+```xml
+
+```
+
+当调用出错时,抛出指定的 Exception:
+
+```xml
+
+```
+
+### force 和 fail
+
+在 `2.6.6` 以上的版本,可以开始在 Spring XML 配置文件中使用 `fail:` 和 `force:`。`force:` 代表强制使用 
Mock 行为,在这种情况下不会走远程调用。`fail:` 与默认行为一致,只有当远程调用发生错误时才使用 Mock 行为。`force:` 和 
`fail:` 都支持与 `throw` 或者 `return` 组合使用。
+
+强制返回指定值:
+
+```xml
+
+```
+
+强制抛出指定异常:
+
+```xml
+
+```
+
+### 在方法级别配置 Mock
+
+Mock 可以在方法级别上指定,假定 `com.foo.BarService` 上有好几个方法,我们可以单独为 `sayHello()` 方法指定 Mock 
行为。具体配置如下所示,在本例中,只要 `sayHello()` 被调用到时,强制返回 "fake":
+
+```xml
+
+
+
+```
+
 [^1]: Mock 是 Stub 的一个子集,便于服务提供方在客户端执行容错逻辑,因经常需要在出现 RpcException 
(比如网络失败,超时等)时进行容错,而在出现业务异常(比如登录用户名密码错误)时不需要容错,如果用 Stub,可能就需要捕获并依赖 RpcException 
类,而用 Mock 就可以不依赖 RpcException,因为它的约定就是只有出现 RpcException 时才执行。
 [^2]: 在 interface 旁放一个 Mock 实现,它实现 BarService 接口,并有一个无参构造函数



[incubator-dubbo-website] branch asf-site updated (1a90a25 -> 2202024)

2018-11-06 Thread iluo
This is an automated email from the ASF dual-hosted git repository.

iluo pushed a change to branch asf-site
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-website.git.


from 1a90a25  build
 new 5d305c1  enhance doc to explain mock behavior futher
 new 2202024  rebuild website

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 docs/en-us/user/demos/local-mock.md   | 53 +++
 docs/zh-cn/user/demos/local-mock.md   | 53 +++
 en-us/docs/user/demos/local-mock.html | 32 +
 en-us/docs/user/demos/local-mock.json |  2 +-
 zh-cn/docs/user/demos/local-mock.html | 32 +
 zh-cn/docs/user/demos/local-mock.json |  2 +-
 6 files changed, 172 insertions(+), 2 deletions(-)



[incubator-dubbo-website] 02/02: rebuild website

2018-11-06 Thread iluo
This is an automated email from the ASF dual-hosted git repository.

iluo pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-website.git

commit 2202024983fe7872e84c345c97154d3d36f6d87b
Author: beiwei30 
AuthorDate: Tue Nov 6 16:49:00 2018 +0800

rebuild website
---
 en-us/docs/user/demos/local-mock.html | 32 
 en-us/docs/user/demos/local-mock.json |  2 +-
 zh-cn/docs/user/demos/local-mock.html | 32 
 zh-cn/docs/user/demos/local-mock.json |  2 +-
 4 files changed, 66 insertions(+), 2 deletions(-)

diff --git a/en-us/docs/user/demos/local-mock.html 
b/en-us/docs/user/demos/local-mock.html
index 3ded33c..b5bc8cd 100644
--- a/en-us/docs/user/demos/local-mock.html
+++ b/en-us/docs/user/demos/local-mock.html
@@ -40,6 +40,38 @@
 Consider changing to Mock implementation and return null in Mock 
implementation. If you just want to simply ignore the exception, 
2.0.11 version or later version is available:
 dubbo:reference interface="com.foo.BarService" mock="return null" 
/
 
+Advanced Usage
+return
+return can be used to return an object's string representation 
as the mocked return value. The legal values incude:
+
+empty: empty value, default value for primary type, and empty 
value for collections.
+null: null
+true: true
+false: false
+JSON format: a mocked return value in JSON format, will be 
deserialized at runtime
+
+throw
+throw can be used to throw an exception object as the mocked 
return value.
+Throw a default RPCException when invocation gets wrong:
+dubbo:reference interface="com.foo.BarService" mock="throw" 
/
+
+Throw a specified exception when invocation gets wrong:
+dubbo:reference interface="com.foo.BarService" mock="throw 
com.foo.MockException" /
+
+force  fail
+Since 2.6.6 and above, it is possible to use 
fail: and force: in Spring's XML configuration to 
define mock behavior. force: means the mocked value is forced to 
use no matter the invocation gets wrong or not, in fact, the remote invocation 
will not happen at all. fail: is consistent with the default 
behavior, that is, mock happens only when invocation gets wrong. Futhermore, 
both force: and fail: [...]
+Force to return the specified value:
+dubbo:reference interface="com.foo.BarService" mock="force:return 
fake" /
+
+Force to throw the specified exception:
+dubbo:reference interface="com.foo.BarService" mock="force:throw 
com.foo.MockException" /
+
+Specify Mock For Particular Method Only
+Mock behavior can be specified on the method level. Assume there are a 
couple of methods on com.foo.BarService, we can specify the mock 
behavior for one particular method only, say sayHello(). In the 
example below, fake is forced to return everytime when 
sayHello() is called, but other methods will not be effected:
+dubbo:reference id="demoService" 
check="false" 
interface="com.foo.BarService"
+dubbo:parameter 
key="sayHello.mock" value="force:return 
fake"/
+/dubbo:reference
+
 
 
 
diff --git a/en-us/docs/user/demos/local-mock.json 
b/en-us/docs/user/demos/local-mock.json
index b6b6911..8f62100 100644
--- a/en-us/docs/user/demos/local-mock.json
+++ b/en-us/docs/user/demos/local-mock.json
@@ -1,4 +1,4 @@
 {
   "filename": "local-mock.md",
-  "__html": "Local mock\nLocal mock [1] is usually used for service 
downgrade, such as a verification service, the client does not throw an 
exception when the service provider hangs up all the time, but returns the 
authorization failed through the Mock data.\nConfigured in the spring 
configuration file as follows:\nLocal mock\nLocal mock [1] is usually used for service 
downgrade, such as a verification service, the client does not throw an 
exception when the service provider hangs up all the time, but returns the 
authorization failed through the Mock data.\nConfigured in the spring 
configuration file as follows:\n请考虑改为 Mock 实现,并在 Mock 实现中 return null。如果只是想简单的忽略异常,在 2.0.11 
以上版本可用:
 dubbo:reference interface="com.foo.BarService" mock="return null" 
/
 
+进阶用法
+return
+使用 return 来返回一个字符串表示的对象,作为 Mock 的返回值。合法的字符串可以是:
+
+empty: 代表空,基本类型的默认值,或者集合类的空值
+null: null
+true: true
+false: false
+JSON 格式: 反序列化 JSON 所得到的对象
+
+throw
+使用 throw 来返回一个 Exception 对象,作为 Mock 的返回值。
+当调用出错时,抛出一个默认的 RPCException:
+dubbo:reference interface="com.foo.BarService" mock="throw" 
/
+
+当调用出错时,抛出指定的 Exception:
+dubbo:reference interface="com.foo.BarService" mock="throw 
com.foo.MockException" /
+
+force 和 fail
+在 2.6.6 以上的版本,可以开始在 Spring XML 配置文件中使用 fail: 和 
force:。force: 代表强制使用 Mock 
行为,在这种情况下不会走远程调用。fail: 与默认行为一致,只有当远程调用发生错误时才使用 Mock 
行为。force: 和 fail: 都支持与 throw 或者 
return 组合使用。
+强制返回指定值:
+dubbo:reference interface="com.foo.BarService" mock="force:return 
fake" /
+
+强制抛出指定异常:
+dubbo:reference interface="com.foo.BarService" mock="force:throw 
com.foo.MockException" /
+
+在方法级别配置 Mock
+Mock 可以在方法级别上指定,假定 com.foo.BarService 上有好几个方法,我们可以单独为 
sayHello() 方法指定 Mock 行为。具体配置如下所示,在本例中,只要 sayHello() 
被调用到时,强制返回