beiwei30 closed pull request #1758: Config api unit test
URL: https://github.com/apache/incubator-dubbo/pull/1758
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/ArgumentConfig.java
 
b/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/ArgumentConfig.java
index 61fff8defc..e752726a0c 100644
--- 
a/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/ArgumentConfig.java
+++ 
b/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/ArgumentConfig.java
@@ -27,7 +27,7 @@
 
     private static final long serialVersionUID = -2165482463925213595L;
 
-    //arugment index -1 represents not set
+    //argument: index -1 represents not set
     private Integer index = -1;
 
     //argument type
diff --git 
a/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/ApplicationConfigTest.java
 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/ApplicationConfigTest.java
new file mode 100644
index 0000000000..f60bb85698
--- /dev/null
+++ 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/ApplicationConfigTest.java
@@ -0,0 +1,177 @@
+/*
+ * 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 com.alibaba.dubbo.config;
+
+import com.alibaba.dubbo.common.Constants;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasEntry;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.sameInstance;
+import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
+import static org.junit.Assert.assertThat;
+
+public class ApplicationConfigTest {
+    @Test
+    public void testName() throws Exception {
+        ApplicationConfig application = new ApplicationConfig();
+        application.setName("app");
+        assertThat(application.getName(), equalTo("app"));
+        application = new ApplicationConfig("app2");
+        assertThat(application.getName(), equalTo("app2"));
+        Map<String, String> parameters = new HashMap<String, String>();
+        ApplicationConfig.appendParameters(parameters, application);
+        assertThat(parameters, hasEntry(Constants.APPLICATION_KEY, "app2"));
+    }
+
+    @Test
+    public void testVersion() throws Exception {
+        ApplicationConfig application = new ApplicationConfig("app");
+        application.setVersion("1.0.0");
+        assertThat(application.getVersion(), equalTo("1.0.0"));
+        Map<String, String> parameters = new HashMap<String, String>();
+        ApplicationConfig.appendParameters(parameters, application);
+        assertThat(parameters, hasEntry("application.version", "1.0.0"));
+    }
+
+    @Test
+    public void testOwner() throws Exception {
+        ApplicationConfig application = new ApplicationConfig("app");
+        application.setOwner("owner");
+        assertThat(application.getOwner(), equalTo("owner"));
+    }
+
+    @Test
+    public void testOrganization() throws Exception {
+        ApplicationConfig application = new ApplicationConfig("app");
+        application.setOrganization("org");
+        assertThat(application.getOrganization(), equalTo("org"));
+    }
+
+    @Test
+    public void testArchitecture() throws Exception {
+        ApplicationConfig application = new ApplicationConfig("app");
+        application.setArchitecture("arch");
+        assertThat(application.getArchitecture(), equalTo("arch"));
+    }
+
+    @Test
+    public void testEnvironment1() throws Exception {
+        ApplicationConfig application = new ApplicationConfig("app");
+        application.setEnvironment("develop");
+        assertThat(application.getEnvironment(), equalTo("develop"));
+        application.setEnvironment("test");
+        assertThat(application.getEnvironment(), equalTo("test"));
+        application.setEnvironment("product");
+        assertThat(application.getEnvironment(), equalTo("product"));
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void testEnvironment2() throws Exception {
+        ApplicationConfig application = new ApplicationConfig("app");
+        application.setEnvironment("illegal-env");
+    }
+
+    @Test
+    public void testRegistry() throws Exception {
+        ApplicationConfig application = new ApplicationConfig("app");
+        RegistryConfig registry = new RegistryConfig();
+        application.setRegistry(registry);
+        assertThat(application.getRegistry(), sameInstance(registry));
+        application.setRegistries(Collections.singletonList(registry));
+        assertThat(application.getRegistries(), contains(registry));
+        assertThat(application.getRegistries(), hasSize(1));
+    }
+
+    @Test
+    public void testMonitor() throws Exception {
+        ApplicationConfig application = new ApplicationConfig("app");
+        application.setMonitor(new MonitorConfig("monitor-addr"));
+        assertThat(application.getMonitor().getAddress(), 
equalTo("monitor-addr"));
+        application.setMonitor("monitor-addr");
+        assertThat(application.getMonitor().getAddress(), 
equalTo("monitor-addr"));
+    }
+
+    @Test
+    public void testLogger() throws Exception {
+        ApplicationConfig application = new ApplicationConfig("app");
+        application.setLogger("log4j");
+        assertThat(application.getLogger(), equalTo("log4j"));
+    }
+
+    @Test
+    public void testDefault() throws Exception {
+        ApplicationConfig application = new ApplicationConfig("app");
+        application.setDefault(true);
+        assertThat(application.isDefault(), is(true));
+    }
+
+    @Test
+    public void testDumpDirectory() throws Exception {
+        ApplicationConfig application = new ApplicationConfig("app");
+        application.setDumpDirectory("/dump");
+        assertThat(application.getDumpDirectory(), equalTo("/dump"));
+        Map<String, String> parameters = new HashMap<String, String>();
+        ApplicationConfig.appendParameters(parameters, application);
+        assertThat(parameters, hasEntry(Constants.DUMP_DIRECTORY, "/dump"));
+    }
+
+    @Test
+    public void testQosEnable() throws Exception {
+        ApplicationConfig application = new ApplicationConfig("app");
+        application.setQosEnable(true);
+        assertThat(application.getQosEnable(), is(true));
+        Map<String, String> parameters = new HashMap<String, String>();
+        ApplicationConfig.appendParameters(parameters, application);
+        assertThat(parameters, hasEntry(Constants.QOS_ENABLE, "true"));
+    }
+
+    @Test
+    public void testQosPort() throws Exception {
+        ApplicationConfig application = new ApplicationConfig("app");
+        application.setQosPort(8080);
+        assertThat(application.getQosPort(), equalTo(8080));
+    }
+
+    @Test
+    public void testQosAcceptForeignIp() throws Exception {
+        ApplicationConfig application = new ApplicationConfig("app");
+        application.setQosAcceptForeignIp(true);
+        assertThat(application.getQosAcceptForeignIp(), is(true));
+        Map<String, String> parameters = new HashMap<String, String>();
+        ApplicationConfig.appendParameters(parameters, application);
+        assertThat(parameters, hasEntry(Constants.ACCEPT_FOREIGN_IP, "true"));
+    }
+
+    @Test
+    public void testParameters() throws Exception {
+        ApplicationConfig application = new ApplicationConfig("app");
+        application.setQosAcceptForeignIp(true);
+        Map<String, String> parameters = new HashMap<String, String>();
+        parameters.put("k1", "v1");
+        ApplicationConfig.appendParameters(parameters, application);
+        assertThat(parameters, hasEntry("k1", "v1"));
+        assertThat(parameters, hasEntry(Constants.ACCEPT_FOREIGN_IP, "true"));
+    }
+}
diff --git 
a/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/ArgumentConfigTest.java
 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/ArgumentConfigTest.java
new file mode 100644
index 0000000000..4e1276f3a5
--- /dev/null
+++ 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/ArgumentConfigTest.java
@@ -0,0 +1,63 @@
+/*
+ * 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 com.alibaba.dubbo.config;
+
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasEntry;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+public class ArgumentConfigTest {
+    @Test
+    public void testIndex() throws Exception {
+        ArgumentConfig argument = new ArgumentConfig();
+        argument.setIndex(1);
+        assertThat(argument.getIndex(), is(1));
+    }
+
+    @Test
+    public void testType() throws Exception {
+        ArgumentConfig argument = new ArgumentConfig();
+        argument.setType("int");
+        assertThat(argument.getType(), equalTo("int"));
+    }
+
+    @Test
+    public void testCallback() throws Exception {
+        ArgumentConfig argument = new ArgumentConfig();
+        argument.setCallback(true);
+        assertThat(argument.isCallback(), is(true));
+    }
+
+    @Test
+    public void testArguments() throws Exception {
+        ArgumentConfig argument = new ArgumentConfig();
+        argument.setIndex(1);
+        argument.setType("int");
+        argument.setCallback(true);
+        Map<String, String> parameters = new HashMap<String, String>();
+        AbstractServiceConfig.appendParameters(parameters, argument);
+        assertThat(parameters, hasEntry("callback", "true"));
+        assertThat(parameters.size(), is(1));
+    }
+}
diff --git 
a/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/ConsumerConfigTest.java
 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/ConsumerConfigTest.java
new file mode 100644
index 0000000000..4eb2d4979d
--- /dev/null
+++ 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/ConsumerConfigTest.java
@@ -0,0 +1,53 @@
+/*
+ * 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 com.alibaba.dubbo.config;
+
+import org.junit.Test;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+public class ConsumerConfigTest {
+    @Test
+    public void testTimeout() throws Exception {
+        try {
+            System.clearProperty("sun.rmi.transport.tcp.responseTimeout");
+            ConsumerConfig consumer = new ConsumerConfig();
+            consumer.setTimeout(10);
+            assertThat(consumer.getTimeout(), is(10));
+            
assertThat(System.getProperty("sun.rmi.transport.tcp.responseTimeout"), 
equalTo("10"));
+        } finally {
+            System.clearProperty("sun.rmi.transport.tcp.responseTimeout");
+        }
+    }
+
+    @Test
+    public void testDefault() throws Exception {
+        ConsumerConfig consumer = new ConsumerConfig();
+        consumer.setDefault(true);
+        assertThat(consumer.isDefault(), is(true));
+    }
+
+    @Test
+    public void testClient() throws Exception {
+        ConsumerConfig consumer = new ConsumerConfig();
+        consumer.setClient("client");
+        assertThat(consumer.getClient(), equalTo("client"));
+    }
+}
diff --git 
a/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MethodConfigTest.java
 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MethodConfigTest.java
new file mode 100644
index 0000000000..d3ca181465
--- /dev/null
+++ 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MethodConfigTest.java
@@ -0,0 +1,182 @@
+/*
+ * 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 com.alibaba.dubbo.config;
+
+import com.alibaba.dubbo.common.Constants;
+import org.hamcrest.Matchers;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasEntry;
+import static org.hamcrest.Matchers.hasKey;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.assertThat;
+
+public class MethodConfigTest {
+    @Test
+    public void testName() throws Exception {
+        MethodConfig method = new MethodConfig();
+        method.setName("hello");
+        assertThat(method.getName(), equalTo("hello"));
+        Map<String, String> parameters = new HashMap<String, String>();
+        MethodConfig.appendParameters(parameters, method);
+        assertThat(parameters, not(hasKey("name")));
+    }
+
+    @Test
+    public void testStat() throws Exception {
+        MethodConfig method = new MethodConfig();
+        method.setStat(10);
+        assertThat(method.getStat(), equalTo(10));
+    }
+
+    @Test
+    public void testRetry() throws Exception {
+        MethodConfig method = new MethodConfig();
+        method.setRetry(true);
+        assertThat(method.isRetry(), is(true));
+    }
+
+    @Test
+    public void testReliable() throws Exception {
+        MethodConfig method = new MethodConfig();
+        method.setReliable(true);
+        assertThat(method.isReliable(), is(true));
+    }
+
+    @Test
+    public void testExecutes() throws Exception {
+        MethodConfig method = new MethodConfig();
+        method.setExecutes(10);
+        assertThat(method.getExecutes(), equalTo(10));
+    }
+
+    @Test
+    public void testDeprecated() throws Exception {
+        MethodConfig method = new MethodConfig();
+        method.setDeprecated(true);
+        assertThat(method.getDeprecated(), is(true));
+    }
+
+    @Test
+    public void testArguments() throws Exception {
+        MethodConfig method = new MethodConfig();
+        ArgumentConfig argument = new ArgumentConfig();
+        method.setArguments(Collections.singletonList(argument));
+        assertThat(method.getArguments(), contains(argument));
+        assertThat(method.getArguments(), Matchers.<ArgumentConfig>hasSize(1));
+    }
+
+    @Test
+    public void testSticky() throws Exception {
+        MethodConfig method = new MethodConfig();
+        method.setSticky(true);
+        assertThat(method.getSticky(), is(true));
+    }
+
+    @Test
+    public void testOnreturn() throws Exception {
+        MethodConfig method = new MethodConfig();
+        method.setOnreturn("on-return-object");
+        assertThat(method.getOnreturn(), equalTo((Object) "on-return-object"));
+        Map<Object, Object> attribute = new HashMap<Object, Object>();
+        MethodConfig.appendAttributes(attribute, method);
+        assertThat(attribute, hasEntry((Object) 
Constants.ON_RETURN_INSTANCE_KEY, (Object) "on-return-object"));
+        Map<String, String> parameters = new HashMap<String, String>();
+        MethodConfig.appendParameters(parameters, method);
+        assertThat(parameters.size(), is(0));
+    }
+
+    @Test
+    public void testOnreturnMethod() throws Exception {
+        MethodConfig method = new MethodConfig();
+        method.setOnreturnMethod("on-return-method");
+        assertThat(method.getOnreturnMethod(), equalTo("on-return-method"));
+        Map<Object, Object> attribute = new HashMap<Object, Object>();
+        MethodConfig.appendAttributes(attribute, method);
+        assertThat(attribute, hasEntry((Object) 
Constants.ON_RETURN_METHOD_KEY, (Object) "on-return-method"));
+        Map<String, String> parameters = new HashMap<String, String>();
+        MethodConfig.appendParameters(parameters, method);
+        assertThat(parameters.size(), is(0));
+    }
+
+    @Test
+    public void testOnthrow() throws Exception {
+        MethodConfig method = new MethodConfig();
+        method.setOnthrow("on-throw-object");
+        assertThat(method.getOnthrow(), equalTo((Object) "on-throw-object"));
+        Map<Object, Object> attribute = new HashMap<Object, Object>();
+        MethodConfig.appendAttributes(attribute, method);
+        assertThat(attribute, hasEntry((Object) 
Constants.ON_THROW_INSTANCE_KEY, (Object) "on-throw-object"));
+        Map<String, String> parameters = new HashMap<String, String>();
+        MethodConfig.appendParameters(parameters, method);
+        assertThat(parameters.size(), is(0));
+    }
+
+    @Test
+    public void testOnthrowMethod() throws Exception {
+        MethodConfig method = new MethodConfig();
+        method.setOnthrowMethod("on-throw-method");
+        assertThat(method.getOnthrowMethod(), equalTo("on-throw-method"));
+        Map<Object, Object> attribute = new HashMap<Object, Object>();
+        MethodConfig.appendAttributes(attribute, method);
+        assertThat(attribute, hasEntry((Object) Constants.ON_THROW_METHOD_KEY, 
(Object) "on-throw-method"));
+        Map<String, String> parameters = new HashMap<String, String>();
+        MethodConfig.appendParameters(parameters, method);
+        assertThat(parameters.size(), is(0));
+    }
+
+    @Test
+    public void testOninvoke() throws Exception {
+        MethodConfig method = new MethodConfig();
+        method.setOninvoke("on-invoke-object");
+        assertThat(method.getOninvoke(), equalTo((Object) "on-invoke-object"));
+        Map<Object, Object> attribute = new HashMap<Object, Object>();
+        MethodConfig.appendAttributes(attribute, method);
+        assertThat(attribute, hasEntry((Object) 
Constants.ON_INVOKE_INSTANCE_KEY, (Object) "on-invoke-object"));
+        Map<String, String> parameters = new HashMap<String, String>();
+        MethodConfig.appendParameters(parameters, method);
+        assertThat(parameters.size(), is(0));
+    }
+
+    @Test
+    public void testOninvokeMethod() throws Exception {
+        MethodConfig method = new MethodConfig();
+        method.setOninvokeMethod("on-invoke-method");
+        assertThat(method.getOninvokeMethod(), equalTo("on-invoke-method"));
+        Map<Object, Object> attribute = new HashMap<Object, Object>();
+        MethodConfig.appendAttributes(attribute, method);
+        assertThat(attribute, hasEntry((Object) 
Constants.ON_INVOKE_METHOD_KEY, (Object) "on-invoke-method"));
+        Map<String, String> parameters = new HashMap<String, String>();
+        MethodConfig.appendParameters(parameters, method);
+        assertThat(parameters.size(), is(0));
+    }
+
+    @Test
+    public void testReturn() throws Exception {
+        MethodConfig method = new MethodConfig();
+        method.setReturn(true);
+        assertThat(method.isReturn(), is(true));
+    }
+}
diff --git 
a/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MockCodec.java
 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MockCodec.java
new file mode 100644
index 0000000000..51867ae008
--- /dev/null
+++ 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MockCodec.java
@@ -0,0 +1,37 @@
+/*
+ * 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 com.alibaba.dubbo.config;
+
+import com.alibaba.dubbo.remoting.Channel;
+import com.alibaba.dubbo.remoting.Codec;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class MockCodec implements Codec {
+    @Override
+    public void encode(Channel channel, OutputStream output, Object message) 
throws IOException {
+
+    }
+
+    @Override
+    public Object decode(Channel channel, InputStream input) throws 
IOException {
+        return null;
+    }
+}
diff --git 
a/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MockDispatcher.java
 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MockDispatcher.java
new file mode 100644
index 0000000000..7691f31150
--- /dev/null
+++ 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MockDispatcher.java
@@ -0,0 +1,29 @@
+/*
+ * 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 com.alibaba.dubbo.config;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.remoting.ChannelHandler;
+import com.alibaba.dubbo.remoting.Dispatcher;
+
+public class MockDispatcher implements Dispatcher {
+    @Override
+    public ChannelHandler dispatch(ChannelHandler handler, URL url) {
+        return null;
+    }
+}
diff --git 
a/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MockExchanger.java
 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MockExchanger.java
new file mode 100644
index 0000000000..32ff0faad6
--- /dev/null
+++ 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MockExchanger.java
@@ -0,0 +1,37 @@
+/*
+ * 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 com.alibaba.dubbo.config;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.remoting.RemotingException;
+import com.alibaba.dubbo.remoting.exchange.ExchangeClient;
+import com.alibaba.dubbo.remoting.exchange.ExchangeHandler;
+import com.alibaba.dubbo.remoting.exchange.ExchangeServer;
+import com.alibaba.dubbo.remoting.exchange.Exchanger;
+
+public class MockExchanger implements Exchanger {
+    @Override
+    public ExchangeServer bind(URL url, ExchangeHandler handler) throws 
RemotingException {
+        return null;
+    }
+
+    @Override
+    public ExchangeClient connect(URL url, ExchangeHandler handler) throws 
RemotingException {
+        return null;
+    }
+}
diff --git 
a/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MockProtocol2.java
 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MockProtocol2.java
new file mode 100644
index 0000000000..be819782a5
--- /dev/null
+++ 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MockProtocol2.java
@@ -0,0 +1,48 @@
+/*
+ * 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 com.alibaba.dubbo.config;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.rpc.Exporter;
+import com.alibaba.dubbo.rpc.Invoker;
+import com.alibaba.dubbo.rpc.Protocol;
+import com.alibaba.dubbo.rpc.RpcException;
+
+public class MockProtocol2 implements Protocol {
+    public static Protocol delegate;
+
+    @Override
+    public int getDefaultPort() {
+        return delegate.getDefaultPort();
+    }
+
+    @Override
+    public <T> Exporter<T> export(Invoker<T> invoker) throws RpcException {
+        return delegate.export(invoker);
+    }
+
+    @Override
+    public <T> Invoker<T> refer(Class<T> type, URL url) throws RpcException {
+        return delegate.refer(type, url);
+    }
+
+    @Override
+    public void destroy() {
+        delegate.destroy();
+    }
+}
diff --git 
a/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MockStatusChecker.java
 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MockStatusChecker.java
new file mode 100644
index 0000000000..29e7751837
--- /dev/null
+++ 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MockStatusChecker.java
@@ -0,0 +1,28 @@
+/*
+ * 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 com.alibaba.dubbo.config;
+
+import com.alibaba.dubbo.common.status.Status;
+import com.alibaba.dubbo.common.status.StatusChecker;
+
+public class MockStatusChecker implements StatusChecker {
+    @Override
+    public Status check() {
+        return null;
+    }
+}
diff --git 
a/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MockTelnetHandler.java
 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MockTelnetHandler.java
new file mode 100644
index 0000000000..3c02f8c39d
--- /dev/null
+++ 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MockTelnetHandler.java
@@ -0,0 +1,29 @@
+/*
+ * 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 com.alibaba.dubbo.config;
+
+import com.alibaba.dubbo.remoting.Channel;
+import com.alibaba.dubbo.remoting.RemotingException;
+import com.alibaba.dubbo.remoting.telnet.TelnetHandler;
+
+public class MockTelnetHandler implements TelnetHandler {
+    @Override
+    public String telnet(Channel channel, String message) throws 
RemotingException {
+        return null;
+    }
+}
diff --git 
a/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MockThreadPool.java
 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MockThreadPool.java
new file mode 100644
index 0000000000..ec6fc50355
--- /dev/null
+++ 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MockThreadPool.java
@@ -0,0 +1,30 @@
+/*
+ * 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 com.alibaba.dubbo.config;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.common.threadpool.ThreadPool;
+
+import java.util.concurrent.Executor;
+
+public class MockThreadPool implements ThreadPool  {
+    @Override
+    public Executor getExecutor(URL url) {
+        return null;
+    }
+}
diff --git 
a/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MockTransporter.java
 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MockTransporter.java
new file mode 100644
index 0000000000..749b9095ef
--- /dev/null
+++ 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MockTransporter.java
@@ -0,0 +1,37 @@
+/*
+ * 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 com.alibaba.dubbo.config;
+
+import com.alibaba.dubbo.common.URL;
+import com.alibaba.dubbo.remoting.ChannelHandler;
+import com.alibaba.dubbo.remoting.Client;
+import com.alibaba.dubbo.remoting.RemotingException;
+import com.alibaba.dubbo.remoting.Server;
+import com.alibaba.dubbo.remoting.Transporter;
+
+public class MockTransporter implements Transporter {
+    @Override
+    public Server bind(URL url, ChannelHandler handler) throws 
RemotingException {
+        return null;
+    }
+
+    @Override
+    public Client connect(URL url, ChannelHandler handler) throws 
RemotingException {
+        return null;
+    }
+}
diff --git 
a/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/ModuleConfigTest.java
 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/ModuleConfigTest.java
new file mode 100644
index 0000000000..0d006296e7
--- /dev/null
+++ 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/ModuleConfigTest.java
@@ -0,0 +1,110 @@
+/*
+ * 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 com.alibaba.dubbo.config;
+
+import org.hamcrest.Matchers;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasEntry;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.sameInstance;
+import static org.junit.Assert.assertThat;
+
+public class ModuleConfigTest {
+    @Test(expected = IllegalStateException.class)
+    public void testName1() throws Exception {
+        ModuleConfig module = new ModuleConfig();
+        Map<String, String> parameters = new HashMap<String, String>();
+        ModuleConfig.appendParameters(parameters, module);
+    }
+
+    @Test
+    public void testName2() throws Exception {
+        ModuleConfig module = new ModuleConfig();
+        module.setName("module-name");
+        assertThat(module.getName(), equalTo("module-name"));
+        assertThat(module.getId(), equalTo("module-name"));
+        Map<String, String> parameters = new HashMap<String, String>();
+        ModuleConfig.appendParameters(parameters, module);
+        assertThat(parameters, hasEntry("module", "module-name"));
+    }
+
+    @Test
+    public void testVersion() throws Exception {
+        ModuleConfig module = new ModuleConfig();
+        module.setName("module-name");
+        module.setVersion("1.0.0");
+        assertThat(module.getVersion(), equalTo("1.0.0"));
+        Map<String, String> parameters = new HashMap<String, String>();
+        ModuleConfig.appendParameters(parameters, module);
+        assertThat(parameters, hasEntry("module.version", "1.0.0"));
+    }
+
+    @Test
+    public void testOwner() throws Exception {
+        ModuleConfig module = new ModuleConfig();
+        module.setOwner("owner");
+        assertThat(module.getOwner(), equalTo("owner"));
+    }
+
+    @Test
+    public void testOrganization() throws Exception {
+        ModuleConfig module = new ModuleConfig();
+        module.setOrganization("org");
+        assertThat(module.getOrganization(), equalTo("org"));
+    }
+
+    @Test
+    public void testRegistry() throws Exception {
+        ModuleConfig module = new ModuleConfig();
+        RegistryConfig registry = new RegistryConfig();
+        module.setRegistry(registry);
+        assertThat(module.getRegistry(), sameInstance(registry));
+    }
+
+    @Test
+    public void testRegistries() throws Exception {
+        ModuleConfig module = new ModuleConfig();
+        RegistryConfig registry = new RegistryConfig();
+        module.setRegistries(Collections.singletonList(registry));
+        assertThat(module.getRegistries(), 
Matchers.<RegistryConfig>hasSize(1));
+        assertThat(module.getRegistries(), contains(registry));
+    }
+
+    @Test
+    public void testMonitor() throws Exception {
+        ModuleConfig module = new ModuleConfig();
+        module.setMonitor("monitor-addr1");
+        assertThat(module.getMonitor().getAddress(), equalTo("monitor-addr1"));
+        module.setMonitor(new MonitorConfig("monitor-addr2"));
+        assertThat(module.getMonitor().getAddress(), equalTo("monitor-addr2"));
+    }
+
+    @Test
+    public void testDefault() throws Exception {
+        ModuleConfig module = new ModuleConfig();
+        module.setDefault(true);
+        assertThat(module.isDefault(), is(true));
+    }
+}
diff --git 
a/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MonitorConfigTest.java
 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MonitorConfigTest.java
new file mode 100644
index 0000000000..49756af6ce
--- /dev/null
+++ 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/MonitorConfigTest.java
@@ -0,0 +1,107 @@
+/*
+ * 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 com.alibaba.dubbo.config;
+
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasEntry;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+public class MonitorConfigTest {
+    @Test
+    public void testAddress() throws Exception {
+        MonitorConfig monitor = new MonitorConfig();
+        monitor.setAddress("monitor-addr");
+        assertThat(monitor.getAddress(), equalTo("monitor-addr"));
+        Map<String, String> parameters = new HashMap<String, String>();
+        MonitorConfig.appendParameters(parameters, monitor);
+        assertThat(parameters.isEmpty(), is(true));
+    }
+
+    @Test
+    public void testProtocol() throws Exception {
+        MonitorConfig monitor = new MonitorConfig();
+        monitor.setProtocol("protocol");
+        assertThat(monitor.getProtocol(), equalTo("protocol"));
+        Map<String, String> parameters = new HashMap<String, String>();
+        MonitorConfig.appendParameters(parameters, monitor);
+        assertThat(parameters.isEmpty(), is(true));
+    }
+
+    @Test
+    public void testUsername() throws Exception {
+        MonitorConfig monitor = new MonitorConfig();
+        monitor.setUsername("user");
+        assertThat(monitor.getUsername(), equalTo("user"));
+        Map<String, String> parameters = new HashMap<String, String>();
+        MonitorConfig.appendParameters(parameters, monitor);
+        assertThat(parameters.isEmpty(), is(true));
+    }
+
+    @Test
+    public void testPassword() throws Exception {
+        MonitorConfig monitor = new MonitorConfig();
+        monitor.setPassword("secret");
+        assertThat(monitor.getPassword(), equalTo("secret"));
+        Map<String, String> parameters = new HashMap<String, String>();
+        MonitorConfig.appendParameters(parameters, monitor);
+        assertThat(parameters.isEmpty(), is(true));
+    }
+
+    @Test
+    public void testGroup() throws Exception {
+        MonitorConfig monitor = new MonitorConfig();
+        monitor.setGroup("group");
+        assertThat(monitor.getGroup(), equalTo("group"));
+    }
+
+    @Test
+    public void testVersion() throws Exception {
+        MonitorConfig monitor = new MonitorConfig();
+        monitor.setVersion("1.0.0");
+        assertThat(monitor.getVersion(), equalTo("1.0.0"));
+    }
+
+    @Test
+    public void testParameters() throws Exception {
+        MonitorConfig monitor = new MonitorConfig();
+        Map<String, String> parameters = Collections.singletonMap("k1", "v1");
+        monitor.setParameters(parameters);
+        assertThat(monitor.getParameters(), hasEntry("k1", "v1"));
+    }
+
+    @Test
+    public void testDefault() throws Exception {
+        MonitorConfig monitor = new MonitorConfig();
+        monitor.setDefault(true);
+        assertThat(monitor.isDefault(), is(true));
+    }
+
+    @Test
+    public void testInterval() throws Exception {
+        MonitorConfig monitor = new MonitorConfig();
+        monitor.setInterval("100");
+        assertThat(monitor.getInterval(), equalTo("100"));
+    }
+}
diff --git 
a/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/ProtocolConfigTest.java
 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/ProtocolConfigTest.java
new file mode 100644
index 0000000000..43f3621e28
--- /dev/null
+++ 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/ProtocolConfigTest.java
@@ -0,0 +1,219 @@
+/*
+ * 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 com.alibaba.dubbo.config;
+
+import com.alibaba.dubbo.common.extension.ExtensionLoader;
+import com.alibaba.dubbo.rpc.Protocol;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasEntry;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+public class ProtocolConfigTest {
+    @Test
+    public void testDestroyAll() throws Exception {
+        Protocol protocol = Mockito.mock(Protocol.class);
+        MockProtocol2.delegate = protocol;
+        ExtensionLoader<Protocol> loader = 
ExtensionLoader.getExtensionLoader(Protocol.class);
+        loader.getExtension("mockprotocol2");
+        ProtocolConfig.destroyAll();
+        Mockito.verify(protocol).destroy();
+    }
+
+    @Test
+    public void testDestroy() throws Exception {
+        Protocol protocol = Mockito.mock(Protocol.class);
+        MockProtocol2.delegate = protocol;
+        ProtocolConfig protocolConfig = new ProtocolConfig();
+        protocolConfig.setName("mockprotocol2");
+        protocolConfig.destory();
+        Mockito.verify(protocol).destroy();
+    }
+
+    @Test
+    public void testName() throws Exception {
+        ProtocolConfig protocol = new ProtocolConfig();
+        protocol.setName("name");
+        Map<String, String> parameters = new HashMap<String, String>();
+        ProtocolConfig.appendParameters(parameters, protocol);
+        assertThat(protocol.getName(), equalTo("name"));
+        assertThat(protocol.getId(), equalTo("name"));
+        assertThat(parameters.isEmpty(), is(true));
+    }
+
+    @Test
+    public void testHost() throws Exception {
+        ProtocolConfig protocol = new ProtocolConfig();
+        protocol.setHost("host");
+        Map<String, String> parameters = new HashMap<String, String>();
+        ProtocolConfig.appendParameters(parameters, protocol);
+        assertThat(protocol.getHost(), equalTo("host"));
+        assertThat(parameters.isEmpty(), is(true));
+    }
+
+    @Test
+    public void testPort() throws Exception {
+        ProtocolConfig protocol = new ProtocolConfig();
+        protocol.setPort(8080);
+        Map<String, String> parameters = new HashMap<String, String>();
+        ProtocolConfig.appendParameters(parameters, protocol);
+        assertThat(protocol.getPort(), equalTo(8080));
+        assertThat(parameters.isEmpty(), is(true));
+    }
+
+    @Test
+    public void testPath() throws Exception {
+        ProtocolConfig protocol = new ProtocolConfig();
+        protocol.setContextpath("context-path");
+        Map<String, String> parameters = new HashMap<String, String>();
+        ProtocolConfig.appendParameters(parameters, protocol);
+        assertThat(protocol.getPath(), equalTo("context-path"));
+        assertThat(protocol.getContextpath(), equalTo("context-path"));
+        assertThat(parameters.isEmpty(), is(true));
+        protocol.setPath("path");
+        assertThat(protocol.getPath(), equalTo("path"));
+        assertThat(protocol.getContextpath(), equalTo("path"));
+    }
+
+    @Test
+    public void testThreads() throws Exception {
+        ProtocolConfig protocol = new ProtocolConfig();
+        protocol.setThreads(10);
+        assertThat(protocol.getThreads(), is(10));
+    }
+
+    @Test
+    public void testIothreads() throws Exception {
+        ProtocolConfig protocol = new ProtocolConfig();
+        protocol.setIothreads(10);
+        assertThat(protocol.getIothreads(), is(10));
+    }
+
+    @Test
+    public void testQueues() throws Exception {
+        ProtocolConfig protocol = new ProtocolConfig();
+        protocol.setQueues(10);
+        assertThat(protocol.getQueues(), is(10));
+    }
+
+    @Test
+    public void testAccepts() throws Exception {
+        ProtocolConfig protocol = new ProtocolConfig();
+        protocol.setAccepts(10);
+        assertThat(protocol.getAccepts(), is(10));
+    }
+
+    @Test
+    public void testCodec() throws Exception {
+        ProtocolConfig protocol = new ProtocolConfig();
+        protocol.setName("dubbo");
+        protocol.setCodec("mockcodec");
+        assertThat(protocol.getCodec(), equalTo("mockcodec"));
+    }
+
+    @Test
+    public void testAccesslog() throws Exception {
+        ProtocolConfig protocol = new ProtocolConfig();
+        protocol.setAccesslog("access.log");
+        assertThat(protocol.getAccesslog(), equalTo("access.log"));
+    }
+
+    @Test
+    public void testTelnet() throws Exception {
+        ProtocolConfig protocol = new ProtocolConfig();
+        protocol.setTelnet("mocktelnethandler");
+        assertThat(protocol.getTelnet(), equalTo("mocktelnethandler"));
+    }
+
+    @Test
+    public void testRegister() throws Exception {
+        ProtocolConfig protocol = new ProtocolConfig();
+        protocol.setRegister(true);
+        assertThat(protocol.isRegister(), is(true));
+    }
+
+    @Test
+    public void testTransporter() throws Exception {
+        ProtocolConfig protocol = new ProtocolConfig();
+        protocol.setTransporter("mocktransporter");
+        assertThat(protocol.getTransporter(), equalTo("mocktransporter"));
+    }
+
+    @Test
+    public void testExchanger() throws Exception {
+        ProtocolConfig protocol = new ProtocolConfig();
+        protocol.setExchanger("mockexchanger");
+        assertThat(protocol.getExchanger(), equalTo("mockexchanger"));
+    }
+
+    @Test
+    public void testDispatcher() throws Exception {
+        ProtocolConfig protocol = new ProtocolConfig();
+        protocol.setDispatcher("mockdispatcher");
+        assertThat(protocol.getDispatcher(), equalTo("mockdispatcher"));
+    }
+
+    @Test
+    public void testNetworker() throws Exception {
+        ProtocolConfig protocol = new ProtocolConfig();
+        protocol.setNetworker("networker");
+        assertThat(protocol.getNetworker(), equalTo("networker"));
+    }
+
+    @Test
+    public void testParameters() throws Exception {
+        ProtocolConfig protocol = new ProtocolConfig();
+        protocol.setParameters(Collections.singletonMap("k1", "v1"));
+        assertThat(protocol.getParameters(), hasEntry("k1", "v1"));
+    }
+
+    @Test
+    public void testDefault() throws Exception {
+        ProtocolConfig protocol = new ProtocolConfig();
+        protocol.setDefault(true);
+        assertThat(protocol.isDefault(), is(true));
+    }
+
+    @Test
+    public void testKeepAlive() throws Exception {
+        ProtocolConfig protocol = new ProtocolConfig();
+        protocol.setKeepAlive(true);
+        assertThat(protocol.getKeepAlive(), is(true));
+    }
+
+    @Test
+    public void testOptimizer() throws Exception {
+        ProtocolConfig protocol = new ProtocolConfig();
+        protocol.setOptimizer("optimizer");
+        assertThat(protocol.getOptimizer(), equalTo("optimizer"));
+    }
+
+    @Test
+    public void testExtension() throws Exception {
+        ProtocolConfig protocol = new ProtocolConfig();
+        protocol.setExtension("extension");
+        assertThat(protocol.getExtension(), equalTo("extension"));
+    }
+}
diff --git 
a/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/ProviderConfigTest.java
 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/ProviderConfigTest.java
new file mode 100644
index 0000000000..ce8b1b11aa
--- /dev/null
+++ 
b/dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/ProviderConfigTest.java
@@ -0,0 +1,219 @@
+/*
+ * 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 com.alibaba.dubbo.config;
+
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasEntry;
+import static org.hamcrest.Matchers.hasKey;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.assertThat;
+
+public class ProviderConfigTest {
+    @Test
+    public void testProtocol() throws Exception {
+        ProviderConfig provider = new ProviderConfig();
+        provider.setProtocol("protocol");
+        assertThat(provider.getProtocol().getName(), equalTo("protocol"));
+    }
+
+    @Test
+    public void testDefault() throws Exception {
+        ProviderConfig provider = new ProviderConfig();
+        provider.setDefault(true);
+        Map<String, String> parameters = new HashMap<String, String>();
+        ProviderConfig.appendParameters(parameters, provider);
+        assertThat(provider.isDefault(), is(true));
+        assertThat(parameters, not(hasKey("default")));
+    }
+
+    @Test
+    public void testHost() throws Exception {
+        ProviderConfig provider = new ProviderConfig();
+        provider.setHost("demo-host");
+        Map<String, String> parameters = new HashMap<String, String>();
+        ProviderConfig.appendParameters(parameters, provider);
+        assertThat(provider.getHost(), equalTo("demo-host"));
+        assertThat(parameters, not(hasKey("host")));
+    }
+
+    @Test
+    public void testPort() throws Exception {
+        ProviderConfig provider = new ProviderConfig();
+        provider.setPort(8080);
+        Map<String, String> parameters = new HashMap<String, String>();
+        ProviderConfig.appendParameters(parameters, provider);
+        assertThat(provider.getPort(), is(8080));
+        assertThat(parameters, not(hasKey("port")));
+    }
+
+    @Test
+    public void testPath() throws Exception {
+        ProviderConfig provider = new ProviderConfig();
+        provider.setPath("/path");
+        Map<String, String> parameters = new HashMap<String, String>();
+        ProviderConfig.appendParameters(parameters, provider);
+        assertThat(provider.getPath(), equalTo("/path"));
+        assertThat(provider.getContextpath(), equalTo("/path"));
+        assertThat(parameters, not(hasKey("path")));
+    }
+
+    @Test
+    public void testContextPath() throws Exception {
+        ProviderConfig provider = new ProviderConfig();
+        provider.setContextpath("/context-path");
+        Map<String, String> parameters = new HashMap<String, String>();
+        ProviderConfig.appendParameters(parameters, provider);
+        assertThat(provider.getContextpath(), equalTo("/context-path"));
+        assertThat(parameters, not(hasKey("/context-path")));
+    }
+
+    @Test
+    public void testThreadpool() throws Exception {
+        ProviderConfig provider = new ProviderConfig();
+        provider.setThreadpool("mockthreadpool");
+        assertThat(provider.getThreadpool(), equalTo("mockthreadpool"));
+    }
+
+    @Test
+    public void testThreads() throws Exception {
+        ProviderConfig provider = new ProviderConfig();
+        provider.setThreads(10);
+        assertThat(provider.getThreads(), is(10));
+    }
+
+    @Test
+    public void testIothreads() throws Exception {
+        ProviderConfig provider = new ProviderConfig();
+        provider.setIothreads(10);
+        assertThat(provider.getIothreads(), is(10));
+    }
+
+    @Test
+    public void testQueues() throws Exception {
+        ProviderConfig provider = new ProviderConfig();
+        provider.setQueues(10);
+        assertThat(provider.getQueues(), is(10));
+    }
+
+    @Test
+    public void testAccepts() throws Exception {
+        ProviderConfig provider = new ProviderConfig();
+        provider.setAccepts(10);
+        assertThat(provider.getAccepts(), is(10));
+    }
+
+    @Test
+    public void testCharset() throws Exception {
+        ProviderConfig provider = new ProviderConfig();
+        provider.setCharset("utf-8");
+        assertThat(provider.getCharset(), equalTo("utf-8"));
+    }
+
+    @Test
+    public void testPayload() throws Exception {
+        ProviderConfig provider = new ProviderConfig();
+        provider.setPayload(10);
+        assertThat(provider.getPayload(), is(10));
+    }
+
+    @Test
+    public void testBuffer() throws Exception {
+        ProviderConfig provider = new ProviderConfig();
+        provider.setBuffer(10);
+        assertThat(provider.getBuffer(), is(10));
+    }
+
+    @Test
+    public void testServer() throws Exception {
+        ProviderConfig provider = new ProviderConfig();
+        provider.setServer("demo-server");
+        assertThat(provider.getServer(), equalTo("demo-server"));
+    }
+
+    @Test
+    public void testClient() throws Exception {
+        ProviderConfig provider = new ProviderConfig();
+        provider.setClient("client");
+        assertThat(provider.getClient(), equalTo("client"));
+    }
+
+    @Test
+    public void testTelnet() throws Exception {
+        ProviderConfig provider = new ProviderConfig();
+        provider.setTelnet("mocktelnethandler");
+        assertThat(provider.getTelnet(), equalTo("mocktelnethandler"));
+    }
+
+    @Test
+    public void testPrompt() throws Exception {
+        ProviderConfig provider = new ProviderConfig();
+        provider.setPrompt("#");
+        Map<String, String> parameters = new HashMap<String, String>();
+        ProviderConfig.appendParameters(parameters, provider);
+        assertThat(provider.getPrompt(), equalTo("#"));
+        assertThat(parameters, hasEntry("prompt", "%23"));
+    }
+
+    @Test
+    public void testStatus() throws Exception {
+        ProviderConfig provider = new ProviderConfig();
+        provider.setStatus("mockstatuschecker");
+        assertThat(provider.getStatus(), equalTo("mockstatuschecker"));
+    }
+
+    @Test
+    public void testTransporter() throws Exception {
+        ProviderConfig provider = new ProviderConfig();
+        provider.setTransporter("mocktransporter");
+        assertThat(provider.getTransporter(), equalTo("mocktransporter"));
+    }
+
+    @Test
+    public void testExchanger() throws Exception {
+        ProviderConfig provider = new ProviderConfig();
+        provider.setExchanger("mockexchanger");
+        assertThat(provider.getExchanger(), equalTo("mockexchanger"));
+    }
+
+    @Test
+    public void testDispatcher() throws Exception {
+        ProviderConfig provider = new ProviderConfig();
+        provider.setDispatcher("mockdispatcher");
+        assertThat(provider.getDispatcher(), equalTo("mockdispatcher"));
+    }
+
+    @Test
+    public void testNetworker() throws Exception {
+        ProviderConfig provider = new ProviderConfig();
+        provider.setNetworker("networker");
+        assertThat(provider.getNetworker(), equalTo("networker"));
+    }
+
+    @Test
+    public void testWait() throws Exception {
+        ProviderConfig provider = new ProviderConfig();
+        provider.setWait(10);
+        assertThat(provider.getWait(), equalTo(10));
+    }
+}
diff --git 
a/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/com.alibaba.dubbo.common.status.StatusChecker
 
b/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/com.alibaba.dubbo.common.status.StatusChecker
new file mode 100644
index 0000000000..14fc47be4c
--- /dev/null
+++ 
b/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/com.alibaba.dubbo.common.status.StatusChecker
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+mockstatuschecker=com.alibaba.dubbo.config.MockStatusChecker
\ No newline at end of file
diff --git 
a/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/com.alibaba.dubbo.common.threadpool.ThreadPool
 
b/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/com.alibaba.dubbo.common.threadpool.ThreadPool
new file mode 100644
index 0000000000..3bfd1aba96
--- /dev/null
+++ 
b/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/com.alibaba.dubbo.common.threadpool.ThreadPool
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+mockthreadpool=com.alibaba.dubbo.config.MockThreadPool
\ No newline at end of file
diff --git 
a/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/com.alibaba.dubbo.remoting.Codec
 
b/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/com.alibaba.dubbo.remoting.Codec
new file mode 100644
index 0000000000..df9bb1531d
--- /dev/null
+++ 
b/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/com.alibaba.dubbo.remoting.Codec
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+mockcodec=com.alibaba.dubbo.config.MockCodec
\ No newline at end of file
diff --git 
a/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/com.alibaba.dubbo.remoting.Dispatcher
 
b/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/com.alibaba.dubbo.remoting.Dispatcher
new file mode 100644
index 0000000000..1b6be40d9c
--- /dev/null
+++ 
b/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/com.alibaba.dubbo.remoting.Dispatcher
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+mockdispatcher=com.alibaba.dubbo.config.MockDispatcher
\ No newline at end of file
diff --git 
a/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/com.alibaba.dubbo.remoting.Transporter
 
b/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/com.alibaba.dubbo.remoting.Transporter
new file mode 100644
index 0000000000..d17c784753
--- /dev/null
+++ 
b/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/com.alibaba.dubbo.remoting.Transporter
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+mocktransporter=com.alibaba.dubbo.config.MockTransporter
\ No newline at end of file
diff --git 
a/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/com.alibaba.dubbo.remoting.exchange.Exchanger
 
b/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/com.alibaba.dubbo.remoting.exchange.Exchanger
new file mode 100644
index 0000000000..3a8ecb9484
--- /dev/null
+++ 
b/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/com.alibaba.dubbo.remoting.exchange.Exchanger
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+mockexchanger=com.alibaba.dubbo.config.MockExchanger
\ No newline at end of file
diff --git 
a/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/com.alibaba.dubbo.remoting.telnet.TelnetHandler
 
b/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/com.alibaba.dubbo.remoting.telnet.TelnetHandler
new file mode 100644
index 0000000000..28104b4bcf
--- /dev/null
+++ 
b/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/com.alibaba.dubbo.remoting.telnet.TelnetHandler
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+mocktelnethandler=com.alibaba.dubbo.config.MockTelnetHandler
+
diff --git 
a/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/com.alibaba.dubbo.rpc.Protocol
 
b/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/com.alibaba.dubbo.rpc.Protocol
index b95dc2e094..30b82bf3a3 100644
--- 
a/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/com.alibaba.dubbo.rpc.Protocol
+++ 
b/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/com.alibaba.dubbo.rpc.Protocol
@@ -1 +1,2 @@
-mockprotocol=com.alibaba.dubbo.config.support.MockProtocol
\ No newline at end of file
+mockprotocol=com.alibaba.dubbo.config.support.MockProtocol
+mockprotocol2=com.alibaba.dubbo.config.MockProtocol2
\ No newline at end of file


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org
For additional commands, e-mail: notifications-h...@dubbo.apache.org

Reply via email to