Repository: apache/dubbo (Java)
Task: Feature (2018-11-07 08:22:39+00:00)

Issue:
Provider should disable mock configuration.
mock configuration should be disabled on provider side.


Discussion:

Patch:
diff --git a/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/ServiceConfig.java b/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/ServiceConfig.java
--- a/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/ServiceConfig.java
+++ b/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/ServiceConfig.java
@@ -819,6 +819,16 @@ public void setGeneric(String generic) {
         }
     }
 
+    @Override
+    public void setMock(Boolean mock) {
+        throw new IllegalArgumentException("mock doesn't support on provider side");
+    }
+
+    @Override
+    public void setMock(String mock) {
+        throw new IllegalArgumentException("mock doesn't support on provider side");
+    }
+
     public List<URL> getExportedUrls() {
         return urls;
     }


Test patch:
diff --git a/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/ServiceConfigTest.java b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/ServiceConfigTest.java
--- a/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/ServiceConfigTest.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/ServiceConfigTest.java
@@ -194,6 +194,18 @@ public void testGeneric2() throws Exception {
         service.setGeneric("illegal");
     }
 
+    @Test(expected = IllegalArgumentException.class)
+    public void testMock() throws Exception {
+        ServiceConfig service = new ServiceConfig();
+        service.setMock("true");
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testMock2() throws Exception {
+        ServiceConfig service = new ServiceConfig();
+        service.setMock(true);
+    }
+
     @Test
     public void testUniqueServiceName() throws Exception {
         ServiceConfig<Greeting> service = new ServiceConfig<Greeting>();