From d6aae075b1d285ead105ce3cc6d4fdcaaaf1c42e Mon Sep 17 00:00:00 2001 From: Ian Luo Date: Wed, 7 Nov 2018 17:44:27 +0800 Subject: [PATCH] #2748: Provider should disable mock configuration (#2750) --- .../java/com/alibaba/dubbo/config/ServiceConfig.java | 10 ++++++++++ .../com/alibaba/dubbo/config/ServiceConfigTest.java | 12 ++++++++++++ 2 files changed, 22 insertions(+) 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 index 8435db5d41a..c02a222afe4 100644 --- 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 @@ -820,6 +820,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 getExportedUrls() { return urls; } 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 index ed5a2e33d7f..2765b9fa18d 100644 --- 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 service = new ServiceConfig();