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 349e990  [SCB-1911]add integration tests for local registry discovery
349e990 is described below

commit 349e9909e9d474afbf728a8cf1d8f610a88ae767
Author: liubao <[email protected]>
AuthorDate: Fri May 15 18:00:43 2020 +0800

    [SCB-1911]add integration tests for local registry discovery
---
 demo/demo-local-registry/README.md                 |   6 +
 .../demo-local-registry-client/pom.xml             |  78 +++++++++
 .../servicecomb/demo/registry/Application.java     |  47 +++++
 .../src/main/resources/application.yml             |  31 ++++
 .../src/main/resources/logback.xml                 |  50 ++++++
 .../demo-local-registry-server/ServerEndpoint.yaml |  43 +++++
 .../src/main/resources/registry.yaml               |  26 +++
 .../servicecomb/demo/registry/LocalRegistryIT.java |  39 +++++
 .../demo-local-registry-server/pom.xml             | 104 +++++++++++
 .../demo/registry/ServerApplication.java           |  33 ++++
 .../servicecomb/demo/registry/ServerEndpoint.java  |  42 +++++
 .../src/main/resources/application.yml             |  29 ++++
 .../src/main/resources/logback.xml                 |  50 ++++++
 demo/demo-local-registry/pom.xml                   |  46 +++++
 demo/demo-register-url-prefix/README.md            |  19 ++
 demo/docker-run-config-local/pom.xml               | 192 +++++++++++++++++++++
 demo/pom.xml                                       |   2 +
 .../registry/ServiceRegistryFactory.java           |   2 +-
 18 files changed, 838 insertions(+), 1 deletion(-)

diff --git a/demo/demo-local-registry/README.md 
b/demo/demo-local-registry/README.md
new file mode 100644
index 0000000..6bb7dd8
--- /dev/null
+++ b/demo/demo-local-registry/README.md
@@ -0,0 +1,6 @@
+This demo is an integration test for testing local registration an discovery.
+
+
+Local registration an discovery is an mechanism that do not using Service 
Center,  
+`Microservice` and `MicroserviceInstance` are constructed from configuration 
file. 
+
diff --git a/demo/demo-local-registry/demo-local-registry-client/pom.xml 
b/demo/demo-local-registry/demo-local-registry-client/pom.xml
new file mode 100644
index 0000000..59ba7bd
--- /dev/null
+++ b/demo/demo-local-registry/demo-local-registry-client/pom.xml
@@ -0,0 +1,78 @@
+<?xml version="1.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.
+  -->
+
+<project
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";
+  xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>demo-local-registry-client</artifactId>
+  <name>Java Chassis::Demo::Local Registry client</name>
+  <parent>
+    <groupId>org.apache.servicecomb.demo</groupId>
+    <artifactId>demo-local-registry</artifactId>
+    <version>2.1.0-SNAPSHOT</version>
+  </parent>
+
+  <properties>
+    <demo.main>org.apache.servicecomb.demo.registry.Application</demo.main>
+  </properties>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>java-chassis-spring-boot-starter-servlet</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb.demo</groupId>
+      <artifactId>demo-schema</artifactId>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>com.github.odavid.maven.plugins</groupId>
+        <artifactId>mixin-maven-plugin</artifactId>
+        <configuration>
+          <mixins>
+            <mixin>
+              <groupId>org.apache.servicecomb.demo</groupId>
+              <artifactId>docker-run-config-local</artifactId>
+              <version>${project.version}</version>
+            </mixin>
+          </mixins>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <profiles>
+    <profile>
+      <id>docker</id>
+      <properties>
+        <demo.service.name>demo-local-registry-server</demo.service.name>
+      </properties>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>io.fabric8</groupId>
+            <artifactId>docker-maven-plugin</artifactId>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+</project>
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
new file mode 100644
index 0000000..a638e0f
--- /dev/null
+++ 
b/demo/demo-local-registry/demo-local-registry-client/src/main/java/org/apache/servicecomb/demo/registry/Application.java
@@ -0,0 +1,47 @@
+/*
+ * 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.demo.registry;
+
+import org.apache.servicecomb.demo.TestMgr;
+import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
+import 
org.apache.servicecomb.serviceregistry.client.LocalServiceRegistryClientImpl;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.web.client.RestTemplate;
+
+@SpringBootApplication
+@EnableServiceComb
+public class Application {
+  public static void main(final String[] args) throws Exception {
+    System.setProperty(LocalServiceRegistryClientImpl.LOCAL_REGISTRY_FILE_KEY, 
"registry.yaml");
+
+    new 
SpringApplicationBuilder().sources(Application.class).web(WebApplicationType.SERVLET).build().run(args);
+
+    runTest();
+  }
+
+  public static void runTest() {
+    RestTemplate template = RestTemplateBuilder.create();
+    TestMgr.check("2", template
+        
.getForObject("cse://demo-local-registry-server/register/url/prefix/getName?name=2",
+            String.class));
+    TestMgr.summary();
+  }
+}
diff --git 
a/demo/demo-local-registry/demo-local-registry-client/src/main/resources/application.yml
 
b/demo/demo-local-registry/demo-local-registry-client/src/main/resources/application.yml
new file mode 100644
index 0000000..9dd3836
--- /dev/null
+++ 
b/demo/demo-local-registry/demo-local-registry-client/src/main/resources/application.yml
@@ -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.
+## ---------------------------------------------------------------------------
+
+server:
+  port: 8082
+
+# java-chassis configurations
+
+APPLICATION_ID: demo-local-registry
+service_description:
+  name: demo-local-registry-client
+  version: 0.0.1
+servicecomb:
+  handler:
+    chain:
+      Consumer:
+        default: loadbalance
\ No newline at end of file
diff --git 
a/demo/demo-local-registry/demo-local-registry-client/src/main/resources/logback.xml
 
b/demo/demo-local-registry/demo-local-registry-client/src/main/resources/logback.xml
new file mode 100644
index 0000000..0d627f2
--- /dev/null
+++ 
b/demo/demo-local-registry/demo-local-registry-client/src/main/resources/logback.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<configuration scan="true">
+  <appender name="STDOUT-TRACING" class="ch.qos.logback.core.ConsoleAppender">
+    <!-- If applicable, can use ch.qos.logback.classic.filter.MarkerFilter -->
+    <filter class="org.apache.servicecomb.foundation.logback.MarkerFilter">
+      <Marker>SERVICECOMB_MARKER</Marker>
+      <OnMismatch>DENY</OnMismatch>
+      <OnMatch>ACCEPT</OnMatch>
+    </filter>
+
+    <encoder>
+      <pattern>%d [%level] [%thread][%X{SERVICECOMB_TRACE_ID}] - %msg 
(%F:%L\)%n</pattern>
+    </encoder>
+  </appender>
+
+  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+    <!-- If applicable, can use ch.qos.logback.classic.filter.MarkerFilter -->
+    <filter class="org.apache.servicecomb.foundation.logback.MarkerFilter">
+      <Marker>SERVICECOMB_MARKER</Marker>
+      <OnMismatch>ACCEPT</OnMismatch>
+      <OnMatch>DENY</OnMatch>
+    </filter>
+
+    <encoder>
+      <pattern>%d [%level] [%thread] - %msg (%F:%L\)%n</pattern>
+    </encoder>
+  </appender>
+
+  <root level="info">
+    <appender-ref ref="STDOUT"/>
+    <appender-ref ref="STDOUT-TRACING"/>
+  </root>
+</configuration>
\ No newline at end of file
diff --git 
a/demo/demo-local-registry/demo-local-registry-client/src/main/resources/microservices/demo-local-registry-server/ServerEndpoint.yaml
 
b/demo/demo-local-registry/demo-local-registry-client/src/main/resources/microservices/demo-local-registry-server/ServerEndpoint.yaml
new file mode 100644
index 0000000..78c9d1b
--- /dev/null
+++ 
b/demo/demo-local-registry/demo-local-registry-client/src/main/resources/microservices/demo-local-registry-server/ServerEndpoint.yaml
@@ -0,0 +1,43 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+swagger: "2.0"
+info:
+  version: "1.0.0"
+  title: "swagger definition for 
org.apache.servicecomb.demo.registry.ServerEndpoint"
+  x-java-interface: "gen.swagger.ServerEndpointIntf"
+basePath: "/register/url/prefix"
+schemes:
+- "http"
+consumes:
+- "application/json"
+produces:
+- "application/json"
+paths:
+  /getName:
+    get:
+      operationId: "getName"
+      parameters:
+      - name: "name"
+        in: "query"
+        required: true
+        type: "string"
+      responses:
+        "200":
+          description: "response of 200"
+          schema:
+            type: "string"
\ No newline at end of file
diff --git 
a/demo/demo-local-registry/demo-local-registry-client/src/main/resources/registry.yaml
 
b/demo/demo-local-registry/demo-local-registry-client/src/main/resources/registry.yaml
new file mode 100644
index 0000000..c5d3a94
--- /dev/null
+++ 
b/demo/demo-local-registry/demo-local-registry-client/src/main/resources/registry.yaml
@@ -0,0 +1,26 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+demo-local-registry-server:
+  - id: "001"
+    version: "1.0"
+    appid: demo-local-registry
+    schemaIds:
+      - ServerEndpoint
+    instances:
+      - endpoints:
+          - rest://localhost:8080
\ No newline at end of file
diff --git 
a/demo/demo-local-registry/demo-local-registry-client/src/test/java/org/apache/servicecomb/demo/registry/LocalRegistryIT.java
 
b/demo/demo-local-registry/demo-local-registry-client/src/test/java/org/apache/servicecomb/demo/registry/LocalRegistryIT.java
new file mode 100644
index 0000000..c2c5ec7
--- /dev/null
+++ 
b/demo/demo-local-registry/demo-local-registry-client/src/test/java/org/apache/servicecomb/demo/registry/LocalRegistryIT.java
@@ -0,0 +1,39 @@
+/*
+ * 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.demo.registry;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+import org.apache.servicecomb.demo.TestMgr;
+import org.junit.Before;
+import org.junit.Test;
+
+public class LocalRegistryIT {
+  @Before
+  public void setUp() throws Exception {
+    TestMgr.errors().clear();
+  }
+
+  @Test
+  public void clientGetsNoError() throws Exception {
+    Application.main(new String[0]);
+
+    assertThat(TestMgr.errors().isEmpty(), is(true));
+  }
+}
diff --git a/demo/demo-local-registry/demo-local-registry-server/pom.xml 
b/demo/demo-local-registry/demo-local-registry-server/pom.xml
new file mode 100644
index 0000000..dc3dee2
--- /dev/null
+++ b/demo/demo-local-registry/demo-local-registry-server/pom.xml
@@ -0,0 +1,104 @@
+<?xml version="1.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.
+  -->
+
+<project
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";
+  xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>demo-local-registry-server</artifactId>
+  <name>Java Chassis::Demo::Local Registry Server</name>
+  <parent>
+    <groupId>org.apache.servicecomb.demo</groupId>
+    <artifactId>demo-local-registry</artifactId>
+    <version>2.1.0-SNAPSHOT</version>
+  </parent>
+
+  <properties>
+    
<demo.main>org.apache.servicecomb.demo.registry.ServerApplication</demo.main>
+  </properties>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>registry-service-center</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework.cloud</groupId>
+      <artifactId>spring-cloud-commons</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework.cloud</groupId>
+      <artifactId>spring-cloud-context</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework.cloud</groupId>
+      <artifactId>spring-cloud-netflix-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>javax.ws.rs</groupId>
+      <artifactId>javax.ws.rs-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>java-chassis-spring-boot-starter-servlet</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>inspector</artifactId>
+    </dependency>
+
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-maven-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>com.github.odavid.maven.plugins</groupId>
+        <artifactId>mixin-maven-plugin</artifactId>
+        <configuration>
+          <mixins>
+            <mixin>
+              <groupId>org.apache.servicecomb.demo</groupId>
+              <artifactId>docker-build-config</artifactId>
+              <version>${project.version}</version>
+            </mixin>
+          </mixins>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <profiles>
+    <profile>
+      <id>docker</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>io.fabric8</groupId>
+            <artifactId>docker-maven-plugin</artifactId>
+          </plugin>
+          <plugin>
+            <groupId>org.commonjava.maven.plugins</groupId>
+            <artifactId>directory-maven-plugin</artifactId>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+</project>
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
new file mode 100644
index 0000000..c2dd825
--- /dev/null
+++ 
b/demo/demo-local-registry/demo-local-registry-server/src/main/java/org/apache/servicecomb/demo/registry/ServerApplication.java
@@ -0,0 +1,33 @@
+/*
+ * 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.demo.registry;
+
+import 
org.apache.servicecomb.serviceregistry.client.LocalServiceRegistryClientImpl;
+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 {
+    System.setProperty(LocalServiceRegistryClientImpl.LOCAL_REGISTRY_FILE_KEY, 
"registry.yaml");
+    new 
SpringApplicationBuilder().sources(ServerApplication.class).web(WebApplicationType.SERVLET).build().run(args);
+  }
+}
diff --git 
a/demo/demo-local-registry/demo-local-registry-server/src/main/java/org/apache/servicecomb/demo/registry/ServerEndpoint.java
 
b/demo/demo-local-registry/demo-local-registry-server/src/main/java/org/apache/servicecomb/demo/registry/ServerEndpoint.java
new file mode 100644
index 0000000..595997f
--- /dev/null
+++ 
b/demo/demo-local-registry/demo-local-registry-server/src/main/java/org/apache/servicecomb/demo/registry/ServerEndpoint.java
@@ -0,0 +1,42 @@
+/*
+ * 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.demo.registry;
+
+import javax.ws.rs.core.MediaType;
+
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.apache.servicecomb.swagger.invocation.context.ContextUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+@RestSchema(schemaId = "ServerEndpoint")
+@RequestMapping(path = "/register/url/prefix", produces = 
MediaType.APPLICATION_JSON)
+public class ServerEndpoint {
+  private static final Logger LOGGER
+      = LoggerFactory.getLogger(ServerEndpoint.class);
+
+  @GetMapping(path = "/getName")
+  public String getName(@RequestParam(name = "name") String name) {
+    ((Invocation) 
ContextUtils.getInvocationContext()).getTraceIdLogger().info(LOGGER, "get name 
invoked.");
+    return name;
+  }
+}
diff --git 
a/demo/demo-local-registry/demo-local-registry-server/src/main/resources/application.yml
 
b/demo/demo-local-registry/demo-local-registry-server/src/main/resources/application.yml
new file mode 100644
index 0000000..08015ff
--- /dev/null
+++ 
b/demo/demo-local-registry/demo-local-registry-server/src/main/resources/application.yml
@@ -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.
+## ---------------------------------------------------------------------------
+
+server:
+  port: 8080
+
+# java-chassis configurations
+
+APPLICATION_ID: demo-local-registry
+service_description:
+  name: demo-local-registry-server
+  version: 0.0.1
+servicecomb:
+  rest:
+    address: 0.0.0.0:8080
\ No newline at end of file
diff --git 
a/demo/demo-local-registry/demo-local-registry-server/src/main/resources/logback.xml
 
b/demo/demo-local-registry/demo-local-registry-server/src/main/resources/logback.xml
new file mode 100644
index 0000000..0d627f2
--- /dev/null
+++ 
b/demo/demo-local-registry/demo-local-registry-server/src/main/resources/logback.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<configuration scan="true">
+  <appender name="STDOUT-TRACING" class="ch.qos.logback.core.ConsoleAppender">
+    <!-- If applicable, can use ch.qos.logback.classic.filter.MarkerFilter -->
+    <filter class="org.apache.servicecomb.foundation.logback.MarkerFilter">
+      <Marker>SERVICECOMB_MARKER</Marker>
+      <OnMismatch>DENY</OnMismatch>
+      <OnMatch>ACCEPT</OnMatch>
+    </filter>
+
+    <encoder>
+      <pattern>%d [%level] [%thread][%X{SERVICECOMB_TRACE_ID}] - %msg 
(%F:%L\)%n</pattern>
+    </encoder>
+  </appender>
+
+  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+    <!-- If applicable, can use ch.qos.logback.classic.filter.MarkerFilter -->
+    <filter class="org.apache.servicecomb.foundation.logback.MarkerFilter">
+      <Marker>SERVICECOMB_MARKER</Marker>
+      <OnMismatch>ACCEPT</OnMismatch>
+      <OnMatch>DENY</OnMatch>
+    </filter>
+
+    <encoder>
+      <pattern>%d [%level] [%thread] - %msg (%F:%L\)%n</pattern>
+    </encoder>
+  </appender>
+
+  <root level="info">
+    <appender-ref ref="STDOUT"/>
+    <appender-ref ref="STDOUT-TRACING"/>
+  </root>
+</configuration>
\ No newline at end of file
diff --git a/demo/demo-local-registry/pom.xml b/demo/demo-local-registry/pom.xml
new file mode 100644
index 0000000..8b373c0
--- /dev/null
+++ b/demo/demo-local-registry/pom.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<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/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.servicecomb.demo</groupId>
+    <artifactId>demo-parent</artifactId>
+    <version>2.1.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>demo-local-registry</artifactId>
+  <name>Java Chassis::Demo::Local Registry</name>
+  <packaging>pom</packaging>
+  <modules>
+    <module>demo-local-registry-server</module>
+    <module>demo-local-registry-client</module>
+  </modules>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>java-chassis-spring-boot-starter-servlet</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>foundation-test-scaffolding</artifactId>
+      <scope>compile</scope>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/demo/demo-register-url-prefix/README.md 
b/demo/demo-register-url-prefix/README.md
new file mode 100644
index 0000000..416a098
--- /dev/null
+++ b/demo/demo-register-url-prefix/README.md
@@ -0,0 +1,19 @@
+This demo is an integration test for testing 
+
+```yaml
+servicecomb:
+  service:
+    registry:
+      registerUrlPrefix: true
+```
+
+When this configuration is enabled, web context path is added to swagger, and 
consumer can 
+invoke with context path
+
+```yaml
+template.getForObject(
+  
"cse://demo-register-url-prefix-server/hellodemo/register/url/prefix/getName?name=2",
+   String.class)
+```
+
+This feature is not recommended for use by default, but for some backward 
capabilities.
diff --git a/demo/docker-run-config-local/pom.xml 
b/demo/docker-run-config-local/pom.xml
new file mode 100644
index 0000000..619c5c0
--- /dev/null
+++ b/demo/docker-run-config-local/pom.xml
@@ -0,0 +1,192 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<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/xsd/maven-4.0.0.xsd";>
+  <parent>
+    <artifactId>demo-parent</artifactId>
+    <groupId>org.apache.servicecomb.demo</groupId>
+    <version>2.1.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>docker-run-config-local</artifactId>
+  <name>Java Chassis::Demo::Docker Run Config Local</name>
+
+  <packaging>pom</packaging>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>io.fabric8</groupId>
+          <artifactId>docker-maven-plugin</artifactId>
+          <configuration>
+            <images>
+              <image>
+                <name>servicecomb/service-center</name>
+                <alias>service-center</alias>
+                <run>
+                  <wait>
+                    <log>server is ready</log>
+                    <tcp>
+                      <ports>
+                        <port>30100</port>
+                      </ports>
+                    </tcp>
+                    <time>60000</time>
+                  </wait>
+                  <ports>
+                    <port>service.center.port:30100</port>
+                  </ports>
+                </run>
+              </image>
+              <image>
+                <name>${demo.service.name}:${project.version}</name>
+                <alias>${demo.service.name}</alias>
+                <run>
+                  <env>
+                    <JAVA_OPTS>
+                      -Dservicecomb.service.publishAddress=${docker.hostname}
+                    </JAVA_OPTS>
+                    
<JAR_PATH>/maven/maven/${demo.service.name}-${project.version}.jar</JAR_PATH>
+                  </env>
+                  <links>
+                    <link>service-center:sc.servicecomb.io</link>
+                  </links>
+                  <wait>
+                    <log>Register microservice instance success</log>
+                    <!--
+                        the log waiting of the plugin has a bug and fails 
frequently
+                        refer to 
https://github.com/fabric8io/docker-maven-plugin/issues/767
+                        this http checking is used as a temporary solution
+                    -->
+
+                    <tcp>
+                      <ports>
+                        <port>8080</port>
+                      </ports>
+                    </tcp>
+                    <time>120000</time>
+                  </wait>
+                  <ports>
+                    <port>7070:7070</port>
+                    <port>8080:8080</port>
+                  </ports>
+                  <dependsOn>
+                    <container>service-center</container>
+                  </dependsOn>
+                </run>
+              </image>
+            </images>
+          </configuration>
+          <executions>
+            <execution>
+              <id>start</id>
+              <phase>pre-integration-test</phase>
+              <goals>
+                <goal>start</goal>
+              </goals>
+            </execution>
+            <execution>
+              <id>stop</id>
+              <phase>post-integration-test</phase>
+              <goals>
+                <goal>stop</goal>
+              </goals>
+            </execution>
+          </executions>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+
+  <profiles>
+    <profile>
+      <id>docker</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.codehaus.gmaven</groupId>
+            <artifactId>gmaven-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>add-default-properties</id>
+                <phase>initialize</phase>
+                <goals>
+                  <goal>execute</goal>
+                </goals>
+                <configuration>
+                  <source>
+                    project.properties.setProperty('docker.hostname', 
'localhost')
+                    log.info("Docker hostname is " + 
project.properties['docker.hostname'])
+                  </source>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-failsafe-plugin</artifactId>
+            <version>2.19.1</version>
+            <configuration>
+              <argLine>${jacoco.failsafe.argLine}</argLine>
+            </configuration>
+            <executions>
+              <execution>
+                <goals>
+                  <goal>integration-test</goal>
+                  <goal>verify</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+    <profile>
+      <id>docker-machine</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.codehaus.gmaven</groupId>
+            <artifactId>gmaven-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>add-dynamic-properties</id>
+                <phase>prepare-package</phase>
+                <goals>
+                  <goal>execute</goal>
+                </goals>
+                <configuration>
+                  <source>
+                    def process = "docker-machine ip default".execute()
+                    process.waitFor()
+                    project.properties.setProperty('docker.hostname', 
process.in.text.trim())
+
+                    log.info("Docker hostname is " + 
project.properties['docker.hostname'])
+                  </source>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+</project>
diff --git a/demo/pom.xml b/demo/pom.xml
index 6d43f5b..68b912a 100644
--- a/demo/pom.xml
+++ b/demo/pom.xml
@@ -34,12 +34,14 @@
     <module>docker-build-config</module>
     <module>docker-run-config</module>
     <module>docker-run-config-edge</module>
+    <module>docker-run-config-local</module>
     <module>demo-schema</module>
     <module>demo-pojo</module>
     <module>demo-jaxrs</module>
     <module>demo-springmvc</module>
     <module>demo-crossapp</module>
     <module>demo-register-url-prefix</module>
+    <module>demo-local-registry</module>
     <module>demo-spring-boot-provider</module>
     <module>demo-spring-boot-transport</module>
     <module>demo-edge</module>
diff --git 
a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/registry/ServiceRegistryFactory.java
 
b/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/registry/ServiceRegistryFactory.java
index a672bbf..6809098 100644
--- 
a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/registry/ServiceRegistryFactory.java
+++ 
b/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/registry/ServiceRegistryFactory.java
@@ -68,7 +68,7 @@ public final class ServiceRegistryFactory {
           "It is running in the local development mode, the local file {} is 
using as the local registry",
           localModeFile);
 
-      return new LocalServiceRegistry(eventBus, serviceRegistryConfig, 
microserviceDefinition);
+      return new LocalServiceRegistry(eventBus, serviceRegistryConfig, 
microserviceDefinition).localFile(localModeFile);
     }
 
     LOGGER.info("It is running in the normal mode, a separated service 
registry is required");

Reply via email to