From 5c971c161a15c68ba6cdf137f9ae6cb8e7ff915a Mon Sep 17 00:00:00 2001 From: Ian Luo Date: Sun, 6 Jan 2019 15:09:31 +0800 Subject: [PATCH] Merge pull request #3143 from beiwei30:prefix, fix prefix, use hypher case instead of camel case. --- .../apache/dubbo/config/AbstractConfig.java | 2 +- .../apache/dubbo/config/ServiceConfig.java | 2 +- .../dubbo/config/ConfigCenterConfigTest.java | 31 +++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ConfigCenterConfigTest.java 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 7f2612aaaa2..45a63f3dee6 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 @@ -140,7 +140,7 @@ private static String getTagName(Class cls) { break; } } - return tag.substring(0, 1).toLowerCase() + tag.substring(1); + return StringUtils.camelToSplitName(tag, "-"); } protected static void appendParameters(Map parameters, Object config) { diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java index 395549a4342..dd14ce95d08 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java @@ -803,7 +803,7 @@ private void checkProtocol() { } protocolConfig.refresh(); if (StringUtils.isNotEmpty(protocolConfig.getId())) { - protocolConfig.setPrefix("dubbo.protocols."); + protocolConfig.setPrefix(Constants.PROTOCOLS_SUFFIX); protocolConfig.refresh(); } } diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ConfigCenterConfigTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ConfigCenterConfigTest.java new file mode 100644 index 00000000000..f5ace5cb136 --- /dev/null +++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ConfigCenterConfigTest.java @@ -0,0 +1,31 @@ +/* + * 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.config; + +import junit.framework.TestCase; +import org.junit.Test; + +public class ConfigCenterConfigTest { + @Test + public void testPrefix() { + ConfigCenterConfig config = new ConfigCenterConfig(); + TestCase.assertEquals("dubbo.config-center", config.getPrefix()); + } +}