Skip to content

Commit

Permalink
Polish apache#3946 : To Add MetadataServiceExporter into dubbo-config…
Browse files Browse the repository at this point in the history
…-api
  • Loading branch information
mercyblitz committed May 21, 2019
1 parent bc41e2d commit 4c8516c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
10 changes: 9 additions & 1 deletion dubbo-config/dubbo-config-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.dubbo</groupId>
Expand Down Expand Up @@ -64,6 +65,13 @@
<artifactId>dubbo-filter-cache</artifactId>
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-metadata</artifactId>
<version>${project.parent.version}</version>
</dependency>

<!-- FIXME, we shouldn't rely on these modules, even in test scope -->
<dependency>
<groupId>org.apache.dubbo</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.metadata.export;
package org.apache.dubbo.config.metadata;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.logger.Logger;
Expand All @@ -27,6 +27,7 @@
import org.apache.dubbo.config.context.ConfigManager;
import org.apache.dubbo.metadata.LocalMetadataService;
import org.apache.dubbo.metadata.MetadataService;
import org.apache.dubbo.metadata.MetadataServiceExporter;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
default=org.apache.dubbo.config.metadata.ConfigurableMetadataServiceExporter
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.metadata.export;
package org.apache.dubbo.config.metadata;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.context.ConfigManager;
import org.apache.dubbo.metadata.MetadataService;
import org.apache.dubbo.metadata.MetadataServiceExporter;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
Expand All @@ -31,8 +32,6 @@
import static org.apache.dubbo.common.constants.CommonConstants.APPLICATION_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
import static org.apache.dubbo.common.constants.ConfigConstants.DUBBO_PROTOCOL;
import static org.apache.dubbo.metadata.export.MetadataServiceExporter.getDefaultExtension;
import static org.junit.jupiter.api.Assertions.assertEquals;

/**
Expand All @@ -57,20 +56,20 @@ public static void init() {

private static ProtocolConfig protocolConfig() {
ProtocolConfig protocolConfig = new ProtocolConfig();
protocolConfig.setName(DUBBO_PROTOCOL);
protocolConfig.setName("mockprotocol");
protocolConfig.setPort(20880);
return protocolConfig;
}

private static RegistryConfig registryConfig() {
RegistryConfig registryConfig = new RegistryConfig();
registryConfig.setAddress("mock://127.0.0.1");
registryConfig.setAddress("mockregistry://127.0.0.1");
return registryConfig;
}

@Test
public void testExportAndUnexport() {
MetadataServiceExporter exporter = getDefaultExtension();
MetadataServiceExporter exporter = new ConfigurableMetadataServiceExporter();
List<URL> urls = exporter.export();

assertEquals(1, urls.size());
Expand All @@ -81,7 +80,7 @@ public void testExportAndUnexport() {
assertEquals(MetadataService.class.getName(), url.getServiceInterface());
assertEquals("test", url.getParameter(GROUP_KEY));
assertEquals(MetadataService.VERSION, url.getParameter(VERSION_KEY));
assertEquals(DUBBO_PROTOCOL, url.getProtocol());
assertEquals("mockprotocol", url.getProtocol());

exporter.unexport();
}
Expand Down

0 comments on commit 4c8516c

Please sign in to comment.