This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git


The following commit(s) were added to refs/heads/master by this push:
     new 1c38898  [SCB-1917]add a test case for testing provider invoke it's 
own service after registry is ready
1c38898 is described below

commit 1c388985eeecfd69e843da89f61d3207a3ad84c0
Author: liubao <[email protected]>
AuthorDate: Tue May 19 11:28:15 2020 +0800

    [SCB-1917]add a test case for testing provider invoke it's own service 
after registry is ready
---
 .../servicecomb/core/bootstrap/SCBBootstrap.java   |  4 ++
 .../servicecomb/demo/registry/Application.java     |  3 ++
 .../demo-local-registry-server/pom.xml             |  4 +-
 ...verApplication.java => SelfServiceInvoker.java} | 32 ++++++++----
 .../demo/registry/ServerApplication.java           | 13 +++++
 providers/provider-springmvc/pom.xml               |  2 +-
 .../reference/TestCseClientHttpRequest.java        |  8 +--
 .../async/CseAsyncClientHttpRequestTest.java       |  6 +--
 .../servicecomb/localregistry/LocalDiscovery.java  |  9 ++--
 .../localregistry/LocalRegistration.java           | 19 ++++---
 .../localregistry/LocalRegistrationStore.java      | 58 ----------------------
 ...DiscoveryStore.java => LocalRegistryStore.java} | 46 ++++++++++++++---
 .../transport/rest/servlet/TestRestServlet.java    |  5 ++
 .../rest/vertx/TestRestServerVerticle.java         |  3 ++
 .../rest/vertx/TestVertxRestDispatcher.java        |  4 ++
 15 files changed, 118 insertions(+), 98 deletions(-)

diff --git 
a/core/src/main/java/org/apache/servicecomb/core/bootstrap/SCBBootstrap.java 
b/core/src/main/java/org/apache/servicecomb/core/bootstrap/SCBBootstrap.java
index 93926c0..389989c 100644
--- a/core/src/main/java/org/apache/servicecomb/core/bootstrap/SCBBootstrap.java
+++ b/core/src/main/java/org/apache/servicecomb/core/bootstrap/SCBBootstrap.java
@@ -18,9 +18,13 @@ package org.apache.servicecomb.core.bootstrap;
 
 import org.apache.servicecomb.core.SCBEngine;
 import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.serviceregistry.DiscoveryManager;
+import org.apache.servicecomb.serviceregistry.RegistrationManager;
 
 public class SCBBootstrap {
   public static SCBEngine createSCBEngineForTest() {
+    RegistrationManager.INSTANCE.init();
+    DiscoveryManager.INSTANCE.init();
     return new SCBEngineForTest();
   }
 }
diff --git 
a/demo/demo-local-registry/demo-local-registry-client/src/main/java/org/apache/servicecomb/demo/registry/Application.java
 
b/demo/demo-local-registry/demo-local-registry-client/src/main/java/org/apache/servicecomb/demo/registry/Application.java
index 82a7de6..7f0c798 100644
--- 
a/demo/demo-local-registry/demo-local-registry-client/src/main/java/org/apache/servicecomb/demo/registry/Application.java
+++ 
b/demo/demo-local-registry/demo-local-registry-client/src/main/java/org/apache/servicecomb/demo/registry/Application.java
@@ -40,5 +40,8 @@ public class Application {
         
.getForObject("cse://demo-local-registry-server/register/url/prefix/getName?name=2",
             String.class));
     TestMgr.summary();
+    if (!TestMgr.errors().isEmpty()) {
+      throw new IllegalStateException("tests failed");
+    }
   }
 }
diff --git a/demo/demo-local-registry/demo-local-registry-server/pom.xml 
b/demo/demo-local-registry/demo-local-registry-server/pom.xml
index 4c0a930..5906a11 100644
--- a/demo/demo-local-registry/demo-local-registry-server/pom.xml
+++ b/demo/demo-local-registry/demo-local-registry-server/pom.xml
@@ -53,8 +53,8 @@
       <artifactId>java-chassis-spring-boot-starter-servlet</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.apache.servicecomb</groupId>
-      <artifactId>inspector</artifactId>
+      <groupId>org.apache.servicecomb.demo</groupId>
+      <artifactId>demo-schema</artifactId>
     </dependency>
 
   </dependencies>
diff --git 
a/demo/demo-local-registry/demo-local-registry-server/src/main/java/org/apache/servicecomb/demo/registry/ServerApplication.java
 
b/demo/demo-local-registry/demo-local-registry-server/src/main/java/org/apache/servicecomb/demo/registry/SelfServiceInvoker.java
similarity index 55%
copy from 
demo/demo-local-registry/demo-local-registry-server/src/main/java/org/apache/servicecomb/demo/registry/ServerApplication.java
copy to 
demo/demo-local-registry/demo-local-registry-server/src/main/java/org/apache/servicecomb/demo/registry/SelfServiceInvoker.java
index bedc30a..078b10c 100644
--- 
a/demo/demo-local-registry/demo-local-registry-server/src/main/java/org/apache/servicecomb/demo/registry/ServerApplication.java
+++ 
b/demo/demo-local-registry/demo-local-registry-server/src/main/java/org/apache/servicecomb/demo/registry/SelfServiceInvoker.java
@@ -17,15 +17,27 @@
 
 package org.apache.servicecomb.demo.registry;
 
-import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
-import org.springframework.boot.WebApplicationType;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.builder.SpringApplicationBuilder;
-
-@SpringBootApplication
-@EnableServiceComb
-public class ServerApplication {
-  public static void main(final String[] args) throws Exception {
-    new 
SpringApplicationBuilder().sources(ServerApplication.class).web(WebApplicationType.SERVLET).build().run(args);
+import java.util.concurrent.CountDownLatch;
+
+import org.apache.servicecomb.core.BootListener;
+import org.apache.servicecomb.provider.pojo.RpcReference;
+import org.springframework.stereotype.Component;
+
+@Component("SelfServiceInvoker")
+public class SelfServiceInvoker implements BootListener {
+  interface IServerEndpoint {
+    String getName(String name);
+  }
+
+  @RpcReference(microserviceName = "demo-local-registry-server", schemaId = 
"ServerEndpoint")
+  IServerEndpoint endpoint;
+
+  public CountDownLatch latch = new CountDownLatch(1);
+
+  public String result = "";
+
+  public void onAfterRegistry(BootEvent event) {
+    result = endpoint.getName("hello");
+    latch.countDown();
   }
 }
diff --git 
a/demo/demo-local-registry/demo-local-registry-server/src/main/java/org/apache/servicecomb/demo/registry/ServerApplication.java
 
b/demo/demo-local-registry/demo-local-registry-server/src/main/java/org/apache/servicecomb/demo/registry/ServerApplication.java
index bedc30a..7d53303 100644
--- 
a/demo/demo-local-registry/demo-local-registry-server/src/main/java/org/apache/servicecomb/demo/registry/ServerApplication.java
+++ 
b/demo/demo-local-registry/demo-local-registry-server/src/main/java/org/apache/servicecomb/demo/registry/ServerApplication.java
@@ -17,6 +17,10 @@
 
 package org.apache.servicecomb.demo.registry;
 
+import java.util.concurrent.TimeUnit;
+
+import org.apache.servicecomb.demo.TestMgr;
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
 import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
 import org.springframework.boot.WebApplicationType;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -27,5 +31,14 @@ import 
org.springframework.boot.builder.SpringApplicationBuilder;
 public class ServerApplication {
   public static void main(final String[] args) throws Exception {
     new 
SpringApplicationBuilder().sources(ServerApplication.class).web(WebApplicationType.SERVLET).build().run(args);
+
+    SelfServiceInvoker invoker = BeanUtils.getBean("SelfServiceInvoker");
+    invoker.latch.await(10, TimeUnit.SECONDS);
+    TestMgr.check(invoker.result, "hello");
+
+    TestMgr.summary();
+    if (!TestMgr.errors().isEmpty()) {
+      System.exit(1);
+    }
   }
 }
diff --git a/providers/provider-springmvc/pom.xml 
b/providers/provider-springmvc/pom.xml
index b84ff7f..50b204b 100644
--- a/providers/provider-springmvc/pom.xml
+++ b/providers/provider-springmvc/pom.xml
@@ -35,7 +35,7 @@
     </dependency>
     <dependency>
       <groupId>org.apache.servicecomb</groupId>
-      <artifactId>registry-service-center</artifactId>
+      <artifactId>registry-local</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>
diff --git 
a/providers/provider-springmvc/src/test/java/org/apache/servicecomb/provider/springmvc/reference/TestCseClientHttpRequest.java
 
b/providers/provider-springmvc/src/test/java/org/apache/servicecomb/provider/springmvc/reference/TestCseClientHttpRequest.java
index 637a71c..869578b 100644
--- 
a/providers/provider-springmvc/src/test/java/org/apache/servicecomb/provider/springmvc/reference/TestCseClientHttpRequest.java
+++ 
b/providers/provider-springmvc/src/test/java/org/apache/servicecomb/provider/springmvc/reference/TestCseClientHttpRequest.java
@@ -24,7 +24,8 @@ import org.apache.servicecomb.core.SCBEngine;
 import org.apache.servicecomb.core.bootstrap.SCBBootstrap;
 import org.apache.servicecomb.foundation.common.Holder;
 import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
-import org.apache.servicecomb.serviceregistry.RegistryUtils;
+import org.apache.servicecomb.serviceregistry.DiscoveryManager;
+import org.apache.servicecomb.serviceregistry.RegistrationManager;
 import org.apache.servicecomb.swagger.invocation.Response;
 import org.junit.AfterClass;
 import org.junit.Assert;
@@ -43,7 +44,7 @@ public class TestCseClientHttpRequest {
   @BeforeClass
   public static void classSetup() {
     ConfigUtil.installDynamicConfig();
-    RegistryUtils.initWithLocalRegistry();
+
     scbEngine = SCBBootstrap.createSCBEngineForTest()
         .addProducerMeta("sid1", new SpringmvcImpl()).run();
   }
@@ -51,6 +52,7 @@ public class TestCseClientHttpRequest {
   @AfterClass
   public static void classTeardown() {
     scbEngine.destroy();
+    DiscoveryManager.renewInstance();
     ArchaiusUtils.resetConfig();
   }
 
@@ -88,7 +90,7 @@ public class TestCseClientHttpRequest {
 
     client.execute();
 
-    Assert.assertArrayEquals(body, (byte[] 
)holder.value.getInvocationArguments().get("input"));
+    Assert.assertArrayEquals(body, (byte[]) 
holder.value.getInvocationArguments().get("input"));
     Assert.assertEquals("123", 
holder.value.getInvocationArguments().get("token"));
   }
 }
diff --git 
a/providers/provider-springmvc/src/test/java/org/apache/servicecomb/provider/springmvc/reference/async/CseAsyncClientHttpRequestTest.java
 
b/providers/provider-springmvc/src/test/java/org/apache/servicecomb/provider/springmvc/reference/async/CseAsyncClientHttpRequestTest.java
index ece0c38..59ac3b3 100644
--- 
a/providers/provider-springmvc/src/test/java/org/apache/servicecomb/provider/springmvc/reference/async/CseAsyncClientHttpRequestTest.java
+++ 
b/providers/provider-springmvc/src/test/java/org/apache/servicecomb/provider/springmvc/reference/async/CseAsyncClientHttpRequestTest.java
@@ -25,9 +25,9 @@ import org.apache.servicecomb.core.Invocation;
 import org.apache.servicecomb.core.SCBEngine;
 import org.apache.servicecomb.core.bootstrap.SCBBootstrap;
 import org.apache.servicecomb.foundation.common.Holder;
+import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
 import 
org.apache.servicecomb.provider.springmvc.reference.CseClientHttpResponse;
 import org.apache.servicecomb.serviceregistry.DiscoveryManager;
-import org.apache.servicecomb.serviceregistry.RegistryUtils;
 import org.apache.servicecomb.swagger.invocation.Response;
 import org.junit.AfterClass;
 import org.junit.Assert;
@@ -47,8 +47,6 @@ public class CseAsyncClientHttpRequestTest {
   @BeforeClass
   public static void classSetup() {
     ConfigUtil.installDynamicConfig();
-    RegistryUtils.initWithLocalRegistry();
-    DiscoveryManager.renewInstance();
     scbEngine = SCBBootstrap.createSCBEngineForTest()
         .addProducerMeta("sid1", new 
CseAsyncClientHttpRequestTestSchema()).run();
   }
@@ -56,6 +54,8 @@ public class CseAsyncClientHttpRequestTest {
   @AfterClass
   public static void classTeardown() {
     scbEngine.destroy();
+    DiscoveryManager.renewInstance();
+    ArchaiusUtils.resetConfig();
   }
 
   @RequestMapping(path = "CseAsyncClientHttpRequestTestSchema")
diff --git 
a/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalDiscovery.java
 
b/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalDiscovery.java
index 8c04c66..7750b03 100644
--- 
a/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalDiscovery.java
+++ 
b/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalDiscovery.java
@@ -29,24 +29,23 @@ public class LocalDiscovery implements Discovery {
 
   public static final String ENABLED = 
"servicecomb.local.registry.discovery.enabled";
 
-  private LocalDiscoveryStore localDiscoveryStore;
+  private LocalRegistryStore localDiscoveryStore = LocalRegistryStore.INSTANCE;
 
   private String revision;
 
   @Override
   public void init() {
-    localDiscoveryStore = new LocalDiscoveryStore();
-    localDiscoveryStore.init();
+    // done in registration
   }
 
   @Override
   public void run() {
-    localDiscoveryStore.run();
+    // done in registration
   }
 
   @Override
   public void destroy() {
-    localDiscoveryStore = null;
+    // done in registration
   }
 
   @Override
diff --git 
a/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistration.java
 
b/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistration.java
index 1811b10..3d10844 100644
--- 
a/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistration.java
+++ 
b/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistration.java
@@ -34,11 +34,10 @@ public class LocalRegistration implements Registration {
 
   public static final String ENABLED = 
"servicecomb.local.registry.registration.enabled";
 
-  private LocalRegistrationStore localRegistrationStore;
+  private LocalRegistryStore localRegistrationStore = 
LocalRegistryStore.INSTANCE;
 
   @Override
   public void init() {
-    localRegistrationStore = new LocalRegistrationStore();
     localRegistrationStore.init();
   }
 
@@ -50,7 +49,7 @@ public class LocalRegistration implements Registration {
 
   @Override
   public void destroy() {
-    localRegistrationStore = null;
+
   }
 
   @Override
@@ -65,38 +64,38 @@ public class LocalRegistration implements Registration {
 
   @Override
   public MicroserviceInstance getMicroserviceInstance() {
-    return localRegistrationStore.getMicroserviceInstance();
+    return localRegistrationStore.getSelfMicroserviceInstance();
   }
 
   @Override
   public Microservice getMicroservice() {
-    return localRegistrationStore.getMicroservice();
+    return localRegistrationStore.getSelfMicroservice();
   }
 
   @Override
   public String getAppId() {
-    return localRegistrationStore.getMicroservice().getAppId();
+    return localRegistrationStore.getSelfMicroservice().getAppId();
   }
 
   @Override
   public boolean updateMicroserviceInstanceStatus(MicroserviceInstanceStatus 
status) {
-    localRegistrationStore.getMicroserviceInstance().setStatus(status);
+    localRegistrationStore.getSelfMicroserviceInstance().setStatus(status);
     return true;
   }
 
   @Override
   public void addSchema(String schemaId, String content) {
-    localRegistrationStore.getMicroservice().addSchema(schemaId, content);
+    localRegistrationStore.getSelfMicroservice().addSchema(schemaId, content);
   }
 
   @Override
   public void addEndpoint(String endpoint) {
-    
localRegistrationStore.getMicroserviceInstance().getEndpoints().add(endpoint);
+    
localRegistrationStore.getSelfMicroserviceInstance().getEndpoints().add(endpoint);
   }
 
   @Override
   public void addBasePath(Collection<BasePath> basePaths) {
-    localRegistrationStore.getMicroservice().getPaths().addAll(basePaths);
+    localRegistrationStore.getSelfMicroservice().getPaths().addAll(basePaths);
   }
 
   @Override
diff --git 
a/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistrationStore.java
 
b/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistrationStore.java
deleted file mode 100644
index e9f3a05..0000000
--- 
a/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistrationStore.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.servicecomb.localregistry;
-
-import org.apache.servicecomb.config.ConfigUtil;
-import org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader;
-import org.apache.servicecomb.serviceregistry.api.registry.Microservice;
-import org.apache.servicecomb.serviceregistry.api.registry.MicroserviceFactory;
-import 
org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance;
-import 
org.apache.servicecomb.serviceregistry.definition.MicroserviceDefinition;
-
-public class LocalRegistrationStore {
-  private Microservice microservice;
-
-  private MicroserviceInstance microserviceInstance;
-
-  public LocalRegistrationStore() {
-
-  }
-
-  public void init() {
-    MicroserviceConfigLoader loader = ConfigUtil.getMicroserviceConfigLoader();
-    MicroserviceDefinition microserviceDefinition = new 
MicroserviceDefinition(loader.getConfigModels());
-    MicroserviceFactory microserviceFactory = new MicroserviceFactory();
-    microservice = microserviceFactory.create(microserviceDefinition);
-    microserviceInstance = microservice.getInstance();
-  }
-
-  public void run() {
-    microservice.setServiceId("[local]-[" + microservice.getAppId()
-        + "]-[" + microservice.getServiceName() + "]");
-    microserviceInstance.setInstanceId(microservice.getServiceId());
-    microserviceInstance.setServiceId(microservice.getServiceId());
-  }
-
-  public Microservice getMicroservice() {
-    return microservice;
-  }
-
-  public MicroserviceInstance getMicroserviceInstance() {
-    return microserviceInstance;
-  }
-}
diff --git 
a/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalDiscoveryStore.java
 
b/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistryStore.java
similarity index 75%
rename from 
service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalDiscoveryStore.java
rename to 
service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistryStore.java
index fd25eee..87f62ef 100644
--- 
a/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalDiscoveryStore.java
+++ 
b/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistryStore.java
@@ -21,6 +21,7 @@ import static 
org.apache.servicecomb.serviceregistry.definition.DefinitionConst.
 
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -28,15 +29,25 @@ import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.stream.Collectors;
 
+import org.apache.servicecomb.config.ConfigUtil;
+import org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader;
 import org.apache.servicecomb.serviceregistry.api.registry.Microservice;
+import org.apache.servicecomb.serviceregistry.api.registry.MicroserviceFactory;
 import 
org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance;
 import 
org.apache.servicecomb.serviceregistry.api.response.FindInstancesResponse;
 import 
org.apache.servicecomb.serviceregistry.client.http.MicroserviceInstances;
+import 
org.apache.servicecomb.serviceregistry.definition.MicroserviceDefinition;
 import org.yaml.snakeyaml.Yaml;
 
-public class LocalDiscoveryStore {
+public class LocalRegistryStore {
   private static final String REGISTRY_FILE_NAME = "registry.yaml";
 
+  public static final LocalRegistryStore INSTANCE = new LocalRegistryStore();
+
+  private Microservice selfMicroservice;
+
+  private MicroserviceInstance selfMicroserviceInstance;
+
   // key is microservice id
   private Map<String, Microservice> microserviceMap = new 
ConcurrentHashMap<>();
 
@@ -44,20 +55,43 @@ public class LocalDiscoveryStore {
   // second key is instance id
   private Map<String, Map<String, MicroserviceInstance>> 
microserviceInstanceMap = new ConcurrentHashMap<>();
 
-  public LocalDiscoveryStore() {
+  public LocalRegistryStore() {
 
   }
 
   public void init() {
-
+    MicroserviceConfigLoader loader = ConfigUtil.getMicroserviceConfigLoader();
+    MicroserviceDefinition microserviceDefinition = new 
MicroserviceDefinition(loader.getConfigModels());
+    MicroserviceFactory microserviceFactory = new MicroserviceFactory();
+    selfMicroservice = microserviceFactory.create(microserviceDefinition);
+    selfMicroserviceInstance = selfMicroservice.getInstance();
+    microserviceMap.clear();
+    microserviceInstanceMap.clear();
   }
 
   public void run() {
+    selfMicroservice.setServiceId("[local]-[" + selfMicroservice.getAppId()
+        + "]-[" + selfMicroservice.getServiceName() + "]");
+    selfMicroserviceInstance.setInstanceId(selfMicroservice.getServiceId());
+    selfMicroserviceInstance.setServiceId(selfMicroservice.getServiceId());
+
     InputStream is = 
this.getClass().getClassLoader().getResourceAsStream(REGISTRY_FILE_NAME);
-    if (is == null) {
-      return;
+    if (is != null) {
+      initFromData(is);
     }
-    initFromData(is);
+
+    microserviceMap.put(selfMicroservice.getServiceId(), selfMicroservice);
+    Map<String, MicroserviceInstance> selfInstanceMap = new HashMap<>(1);
+    selfInstanceMap.put(selfMicroserviceInstance.getInstanceId(), 
selfMicroserviceInstance);
+    microserviceInstanceMap.put(selfMicroservice.getServiceId(), 
selfInstanceMap);
+  }
+
+  public Microservice getSelfMicroservice() {
+    return selfMicroservice;
+  }
+
+  public MicroserviceInstance getSelfMicroserviceInstance() {
+    return selfMicroserviceInstance;
   }
 
   private void initFromData(InputStream is) {
diff --git 
a/transports/transport-rest/transport-rest-servlet/src/test/java/org/apache/servicecomb/transport/rest/servlet/TestRestServlet.java
 
b/transports/transport-rest/transport-rest-servlet/src/test/java/org/apache/servicecomb/transport/rest/servlet/TestRestServlet.java
index eb2564c..a2c965c 100644
--- 
a/transports/transport-rest/transport-rest-servlet/src/test/java/org/apache/servicecomb/transport/rest/servlet/TestRestServlet.java
+++ 
b/transports/transport-rest/transport-rest-servlet/src/test/java/org/apache/servicecomb/transport/rest/servlet/TestRestServlet.java
@@ -21,9 +21,11 @@ import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.servicecomb.config.ConfigUtil;
 import org.apache.servicecomb.core.SCBEngine;
 import org.apache.servicecomb.core.bootstrap.SCBBootstrap;
 import org.apache.servicecomb.foundation.common.Holder;
+import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -38,6 +40,8 @@ public class TestRestServlet {
 
   @Before
   public void setUp() {
+    ConfigUtil.installDynamicConfig();
+
     restservlet = new RestServlet();
 
     SCBBootstrap.createSCBEngineForTest();
@@ -47,6 +51,7 @@ public class TestRestServlet {
   public void tearDown() {
     restservlet = null;
     SCBEngine.getInstance().destroy();
+    ArchaiusUtils.resetConfig();
   }
 
   @Test
diff --git 
a/transports/transport-rest/transport-rest-vertx/src/test/java/org/apache/servicecomb/transport/rest/vertx/TestRestServerVerticle.java
 
b/transports/transport-rest/transport-rest-vertx/src/test/java/org/apache/servicecomb/transport/rest/vertx/TestRestServerVerticle.java
index ee24cf6..d8a4be5 100644
--- 
a/transports/transport-rest/transport-rest-vertx/src/test/java/org/apache/servicecomb/transport/rest/vertx/TestRestServerVerticle.java
+++ 
b/transports/transport-rest/transport-rest-vertx/src/test/java/org/apache/servicecomb/transport/rest/vertx/TestRestServerVerticle.java
@@ -21,6 +21,7 @@ import java.util.HashSet;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import org.apache.servicecomb.config.ConfigUtil;
 import org.apache.servicecomb.core.Endpoint;
 import org.apache.servicecomb.core.SCBEngine;
 import org.apache.servicecomb.core.Transport;
@@ -63,6 +64,7 @@ public class TestRestServerVerticle {
   @SuppressWarnings("deprecation")
   // TODO: vert.x 3.8.3 does not update startListen to promise, so we keep use 
deprecated API now. update in newer version.
   public void setUp() {
+    ConfigUtil.installDynamicConfig();
     instance = new RestServerVerticle();
     startFuture = Future.future();
 
@@ -74,6 +76,7 @@ public class TestRestServerVerticle {
     instance = null;
     startFuture = null;
     SCBEngine.getInstance().destroy();
+    ArchaiusUtils.resetConfig();
   }
 
   @Test
diff --git 
a/transports/transport-rest/transport-rest-vertx/src/test/java/org/apache/servicecomb/transport/rest/vertx/TestVertxRestDispatcher.java
 
b/transports/transport-rest/transport-rest-vertx/src/test/java/org/apache/servicecomb/transport/rest/vertx/TestVertxRestDispatcher.java
index 3b9ac5c..491bb3c 100644
--- 
a/transports/transport-rest/transport-rest-vertx/src/test/java/org/apache/servicecomb/transport/rest/vertx/TestVertxRestDispatcher.java
+++ 
b/transports/transport-rest/transport-rest-vertx/src/test/java/org/apache/servicecomb/transport/rest/vertx/TestVertxRestDispatcher.java
@@ -29,10 +29,12 @@ import org.apache.servicecomb.common.rest.RestConst;
 import org.apache.servicecomb.common.rest.RestProducerInvocation;
 import org.apache.servicecomb.common.rest.VertxRestInvocation;
 import org.apache.servicecomb.common.rest.filter.HttpServerFilter;
+import org.apache.servicecomb.config.ConfigUtil;
 import org.apache.servicecomb.core.SCBEngine;
 import org.apache.servicecomb.core.Transport;
 import org.apache.servicecomb.core.bootstrap.SCBBootstrap;
 import org.apache.servicecomb.core.transport.TransportManager;
+import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
 import org.apache.servicecomb.foundation.vertx.http.HttpServletRequestEx;
 import org.apache.servicecomb.foundation.vertx.http.HttpServletResponseEx;
 import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
@@ -79,6 +81,7 @@ public class TestVertxRestDispatcher {
 
   @Before
   public void setUp() {
+    ConfigUtil.installDynamicConfig();
     dispatcher = new VertxRestDispatcher();
     dispatcher.init(mainRouter);
 
@@ -101,6 +104,7 @@ public class TestVertxRestDispatcher {
   @After
   public void teardown() {
     SCBEngine.getInstance().destroy();
+    ArchaiusUtils.resetConfig();
   }
 
   @Test

Reply via email to