You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2018/06/30 03:15:01 UTC

[GitHub] liubao68 closed pull request #778: [SCB-699] add schemaIds field in register.yaml when mock the Local se…

liubao68 closed pull request #778: [SCB-699] add schemaIds field in register.yaml when mock the Local se…
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/778
 
 
   

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/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/LocalServiceRegistryClientImpl.java b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/LocalServiceRegistryClientImpl.java
index 84c15169d..7daaa030d 100644
--- a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/LocalServiceRegistryClientImpl.java
+++ b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/LocalServiceRegistryClientImpl.java
@@ -118,14 +118,19 @@ private void initFromData(Map<String, Object> data) {
         String appId = (String) serviceConfig.get("appid");
         String version = (String) serviceConfig.get("version");
         String serviceId = (String) serviceConfig.get("id");
-
+        @SuppressWarnings("unchecked")
+        List<String> schemas = (List<String> ) serviceConfig.get("schemaIds");
+        	
         Microservice microservice = new Microservice();
         microservice.setAppId(appId == null ? DEFAULT_APPLICATION_ID : appId);
         microservice.setServiceName(name);
         microservice.setVersion(version);
         microservice.setServiceId(serviceId == null ? UUID.randomUUID().toString() : serviceId);
         microserviceIdMap.put(microservice.getServiceId(), microservice);
-
+        if (schemas != null) {
+            microservice.setSchemas(schemas);
+        }
+        	
         Map<String, MicroserviceInstance> instanceMap = new ConcurrentHashMap<>();
         for (Map<String, Object> instanceConfig : instancesConfig) {
           @SuppressWarnings("unchecked")
diff --git a/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/client/LocalServiceRegistryClientImplTest.java b/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/client/LocalServiceRegistryClientImplTest.java
index 095aa8b2e..7e95be93e 100644
--- a/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/client/LocalServiceRegistryClientImplTest.java
+++ b/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/client/LocalServiceRegistryClientImplTest.java
@@ -190,5 +190,12 @@ public void testGetSchemas() {
     Assert.assertEquals(200, schemasHolder.getStatusCode());
     Assert.assertTrue(schemasHolder.getValue().isEmpty());
   }
+
+  @Test
+  public void testLoadSchemaIdsFromRegistryFile() {
+    Microservice microservice = registryClient.getMicroservice("001");
+    Assert.assertThat(microservice.getSchemas().size(), Is.is(1));
+    Assert.assertTrue(microservice.getSchemas().contains("springmvcHello"));
+  }
 }
 
diff --git a/service-registry/src/test/resources/registry.yaml b/service-registry/src/test/resources/registry.yaml
index ffd495cc2..8cad52c22 100644
--- a/service-registry/src/test/resources/registry.yaml
+++ b/service-registry/src/test/resources/registry.yaml
@@ -19,6 +19,8 @@ springmvctest:
   - id: "001"
     version: "1.0"
     appid: myapp
+    schemaIds:
+      - springmvcHello
     instances:
       - endpoints:
         - rest://127.0.0.1:8080


 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services