You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2018/04/16 09:36:56 UTC

[incubator-servicecomb-java-chassis] 09/13: [SCB-292] chassis support standard parameter validation

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/incubator-servicecomb-java-chassis.git

commit ad72bd701db37fe8eff2f994b63109a0a2e5e390
Author: acsukesh <su...@huawei.com>
AuthorDate: Tue Apr 10 18:08:42 2018 +0530

    [SCB-292] chassis support standard parameter validation
---
 .../servicecomb/demo/jaxrs/client/JaxrsClient.java |  64 ++++++++++
 demo/demo-jaxrs/jaxrs-server/pom.xml               | 129 +++++++++++----------
 .../servicecomb/demo/jaxrs/server/Validator.java}  |  28 +++--
 .../servicecomb/demo/validator/Student.java}       |  44 +++++--
 demo/demo-validator/pom.xml                        |  34 ------
 demo/demo-validator/validator-client/pom.xml       |  55 ---------
 .../client/CodeFirstValidatorRestTemplate.java     | 118 -------------------
 .../demo/validator/client/ValidatorClient.java     |  48 --------
 .../src/main/resources/microservice.yaml           |  29 -----
 demo/demo-validator/validator-server/pom.xml       |  85 --------------
 .../src/main/resources/microservice.yaml           |  33 ------
 demo/pom.xml                                       |   1 -
 .../invocation-validator/pom.xml                   |  68 ++++++-----
 13 files changed, 212 insertions(+), 524 deletions(-)

diff --git a/demo/demo-jaxrs/jaxrs-client/src/main/java/org/apache/servicecomb/demo/jaxrs/client/JaxrsClient.java b/demo/demo-jaxrs/jaxrs-client/src/main/java/org/apache/servicecomb/demo/jaxrs/client/JaxrsClient.java
index 5047a87..8781929 100644
--- a/demo/demo-jaxrs/jaxrs-client/src/main/java/org/apache/servicecomb/demo/jaxrs/client/JaxrsClient.java
+++ b/demo/demo-jaxrs/jaxrs-client/src/main/java/org/apache/servicecomb/demo/jaxrs/client/JaxrsClient.java
@@ -28,9 +28,11 @@ import org.apache.servicecomb.demo.CodeFirstRestTemplate;
 import org.apache.servicecomb.demo.DemoConst;
 import org.apache.servicecomb.demo.TestMgr;
 import org.apache.servicecomb.demo.compute.Person;
+import org.apache.servicecomb.demo.compute.Student;
 import org.apache.servicecomb.foundation.common.utils.BeanUtils;
 import org.apache.servicecomb.foundation.common.utils.Log4jUtils;
 import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
+import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpMethod;
@@ -57,6 +59,7 @@ public class JaxrsClient {
     CodeFirstRestTemplate codeFirstClient = new CodeFirstRestTemplateJaxrs();
     codeFirstClient.testCodeFirst(templateNew, "jaxrs", "/codeFirstJaxrs/");
     testCompute(templateNew);
+    testValidator(templateNew);
   }
 
   private static void testCompute(RestTemplate template) throws Exception {
@@ -76,6 +79,21 @@ public class JaxrsClient {
     }
   }
 
+  private static void testValidator(RestTemplate template) throws Exception {
+    String microserviceName = "jaxrs";
+    for (String transport : DemoConst.transports) {
+      CseContext.getInstance().getConsumerProviderManager().setTransport(microserviceName, transport);
+      TestMgr.setMsg(microserviceName, transport);
+
+      String cseUrlPrefix = "cse://" + microserviceName + "/validator/";
+
+      testValidatorAdd(template, cseUrlPrefix);
+      testValidatorSayHi(template, cseUrlPrefix);
+      testValidatorExchange(template, cseUrlPrefix);
+    }
+  }
+
+
   private static void testGet(RestTemplate template, String cseUrlPrefix) {
     Map<String, String> params = new HashMap<>();
     params.put("a", "5");
@@ -147,4 +165,50 @@ public class JaxrsClient {
     TestMgr.check("hello Tom",
         template.postForObject(cseUrlPrefix + "/compute/testrawjson", jsonPerson, String.class));
   }
+
+  private static void testValidatorAdd(RestTemplate template, String cseUrlPrefix) {
+    Map<String, String> params = new HashMap<>();
+    params.put("a", "5");
+    params.put("b", "3");
+    boolean isExcep = false;
+    try {
+      template.postForObject(cseUrlPrefix + "add", params, Integer.class);
+    } catch (InvocationException e) {
+      isExcep = true;
+      TestMgr.check(490, e.getStatus().getStatusCode());
+    }
+
+    TestMgr.check(true, isExcep);
+  }
+
+  private static void testValidatorSayHi(RestTemplate template, String cseUrlPrefix) {
+    boolean isExcep = false;
+    try {
+      template.exchange(cseUrlPrefix + "sayhi/{name}", HttpMethod.PUT, null, String.class, "te");
+    } catch (InvocationException e) {
+      isExcep = true;
+      TestMgr.check(490, e.getStatus().getStatusCode());
+    }
+    TestMgr.check(true, isExcep);
+  }
+
+  private static void testValidatorExchange(RestTemplate template, String cseUrlPrefix) {
+    HttpHeaders headers = new HttpHeaders();
+    headers.add("Accept", MediaType.APPLICATION_JSON);
+    Student student = new Student();
+    student.setName("");
+    student.setAge(25);
+    boolean isExcep = false;
+    try {
+      HttpEntity<Student> requestEntity = new HttpEntity<>(student, headers);
+      template.exchange(cseUrlPrefix + "/sayhello",
+          HttpMethod.POST,
+          requestEntity,
+          Student.class);
+    } catch (InvocationException e) {
+      isExcep = true;
+      TestMgr.check(490, e.getStatus().getStatusCode());
+    }
+    TestMgr.check(true, isExcep);
+  }
 }
diff --git a/demo/demo-jaxrs/jaxrs-server/pom.xml b/demo/demo-jaxrs/jaxrs-server/pom.xml
index af8de56..0abb64f 100644
--- a/demo/demo-jaxrs/jaxrs-server/pom.xml
+++ b/demo/demo-jaxrs/jaxrs-server/pom.xml
@@ -17,68 +17,69 @@
   -->
 
 <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>
-	<parent>
-		<groupId>org.apache.servicecomb.demo</groupId>
-		<artifactId>demo-jaxrs</artifactId>
-		<version>1.0.0-m2-SNAPSHOT</version>
-	</parent>
-	<artifactId>jaxrs-server</artifactId>
-	<name>Java Chassis::Demo::JAXRS::Server</name>
-
-	<dependencies>
-		<dependency>
-			<groupId>org.apache.servicecomb.demo</groupId>
-			<artifactId>demo-schema</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.servicecomb</groupId>
-			<artifactId>provider-jaxrs</artifactId>
-		</dependency>
-	</dependencies>
-
-	<properties>
-		<demo.main>org.apache.servicecomb.demo.jaxrs.server.JaxrsServer</demo.main>
-	</properties>
-	<build>
-		<plugins>
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-dependency-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>1.0.0-m2-SNAPSHOT</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>
+  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>
+  <parent>
+    <groupId>org.apache.servicecomb.demo</groupId>
+    <artifactId>demo-jaxrs</artifactId>
+    <version>1.0.0-m2-SNAPSHOT</version>
+  </parent>
+  <artifactId>jaxrs-server</artifactId>
+  <name>Java Chassis::Demo::JAXRS::Server</name>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb.demo</groupId>
+      <artifactId>demo-schema</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>provider-jaxrs</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>swagger-invocation-validator</artifactId>
+    </dependency>
+  </dependencies>
+  <properties>
+    <demo.main>org.apache.servicecomb.demo.jaxrs.server.JaxrsServer</demo.main>
+  </properties>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-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>1.0.0-m2-SNAPSHOT</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-validator/validator-server/src/main/java/org/apache/servicecomb/demo/validator/server/CodeFirstJaxrs.java b/demo/demo-jaxrs/jaxrs-server/src/main/java/org/apache/servicecomb/demo/jaxrs/server/Validator.java
similarity index 79%
rename from demo/demo-validator/validator-server/src/main/java/org/apache/servicecomb/demo/validator/server/CodeFirstJaxrs.java
rename to demo/demo-jaxrs/jaxrs-server/src/main/java/org/apache/servicecomb/demo/jaxrs/server/Validator.java
index a9fc320..a87e61f 100644
--- a/demo/demo-validator/validator-server/src/main/java/org/apache/servicecomb/demo/validator/server/CodeFirstJaxrs.java
+++ b/demo/demo-jaxrs/jaxrs-server/src/main/java/org/apache/servicecomb/demo/jaxrs/server/Validator.java
@@ -15,11 +15,11 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.demo.validator.server;
+package org.apache.servicecomb.demo.jaxrs.server;
 
+import javax.validation.Valid;
 import javax.validation.constraints.Min;
 import javax.ws.rs.FormParam;
-import javax.ws.rs.GET;
 import javax.ws.rs.POST;
 import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
@@ -27,20 +27,15 @@ import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 
-import org.apache.servicecomb.core.Const;
+import org.apache.servicecomb.demo.compute.Student;
 import org.apache.servicecomb.provider.rest.common.RestSchema;
 import org.apache.servicecomb.swagger.invocation.context.ContextUtils;
 import org.hibernate.validator.constraints.Length;
 
-@RestSchema(schemaId = "codeFirst")
-@Path("/codeFirstJaxrs")
+@RestSchema(schemaId = "validator")
+@Path("/validator")
 @Produces(MediaType.APPLICATION_JSON)
-public class CodeFirstJaxrs {
-
-  @GET
-  public int defaultPath() {
-    return 100;
-  }
+public class Validator {
 
   @Path("/add")
   @POST
@@ -55,9 +50,12 @@ public class CodeFirstJaxrs {
     return name + " sayhi";
   }
 
-  @Path("/traceId")
-  @GET
-  public String getTraceId() {
-    return ContextUtils.getInvocationContext().getContext(Const.TRACE_ID_NAME);
+  @Path("/sayhello")
+  @POST
+  public Student sayHello(@Valid Student student) {
+    student.setName("hello " + student.getName());
+    student.setAge(student.getAge());
+    return student;
   }
+
 }
diff --git a/demo/demo-validator/validator-server/src/main/java/org/apache/servicecomb/demo/validator/server/ValidatorServer.java b/demo/demo-schema/src/main/java/org/apache/servicecomb/demo/validator/Student.java
similarity index 56%
rename from demo/demo-validator/validator-server/src/main/java/org/apache/servicecomb/demo/validator/server/ValidatorServer.java
rename to demo/demo-schema/src/main/java/org/apache/servicecomb/demo/validator/Student.java
index 5ce0ed0..65feea2 100644
--- a/demo/demo-validator/validator-server/src/main/java/org/apache/servicecomb/demo/validator/server/ValidatorServer.java
+++ b/demo/demo-schema/src/main/java/org/apache/servicecomb/demo/validator/Student.java
@@ -15,14 +15,44 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.demo.validator.server;
+package org.apache.servicecomb.demo.validator;
 
-import org.apache.servicecomb.foundation.common.utils.BeanUtils;
-import org.apache.servicecomb.foundation.common.utils.Log4jUtils;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.NotNull;
 
-public class ValidatorServer {
-  public static void main(String[] args) throws Exception {
-    Log4jUtils.init();
-    BeanUtils.init();
+public class Student {
+  @NotNull
+  private String name;
+
+  @Max(20)
+  private int age;
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public String getName() {
+    return this.name;
+  }
+
+  public Student() {
+  }
+
+  public int getAge() {
+    return age;
+  }
+
+  public void setAge(int age) {
+    this.age = age;
+  }
+
+  public Student(String name, int age) {
+    this.name = name;
+    this.age = age;
+  }
+
+  @Override
+  public String toString() {
+    return name + " " + age;
   }
 }
diff --git a/demo/demo-validator/pom.xml b/demo/demo-validator/pom.xml
deleted file mode 100644
index 2cb5750..0000000
--- a/demo/demo-validator/pom.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?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>1.0.0-m2-SNAPSHOT</version>
-  </parent>
-  <artifactId>demo-validator</artifactId>
-  <name>Java Chassis::Demo::Validator</name>
-  <packaging>pom</packaging>
-  <modules>
-    <module>validator-server</module>
-    <module>validator-client</module>
-  </modules>
-</project>
diff --git a/demo/demo-validator/validator-client/pom.xml b/demo/demo-validator/validator-client/pom.xml
deleted file mode 100644
index 7b906e9..0000000
--- a/demo/demo-validator/validator-client/pom.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-<?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>
-  <parent>
-    <groupId>org.apache.servicecomb.demo</groupId>
-    <artifactId>demo-validator</artifactId>
-    <version>1.0.0-m2-SNAPSHOT</version>
-  </parent>
-  <artifactId>validator-client</artifactId>
-  <name>Java Chassis::Demo::Validator::Client</name>
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.servicecomb.demo</groupId>
-      <artifactId>demo-schema</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.servicecomb</groupId>
-      <artifactId>provider-jaxrs</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.servicecomb</groupId>
-      <artifactId>provider-springmvc</artifactId>
-    </dependency>
-  </dependencies>
-  <properties>
-    <demo.main>org.apache.servicecomb.demo.validator.client.ValidatorClient</demo.main>
-  </properties>
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-dependency-plugin</artifactId>
-      </plugin>
-    </plugins>
-  </build>
-</project>
diff --git a/demo/demo-validator/validator-client/src/main/java/org/apache/servicecomb/demo/validator/client/CodeFirstValidatorRestTemplate.java b/demo/demo-validator/validator-client/src/main/java/org/apache/servicecomb/demo/validator/client/CodeFirstValidatorRestTemplate.java
deleted file mode 100644
index 5026970..0000000
--- a/demo/demo-validator/validator-client/src/main/java/org/apache/servicecomb/demo/validator/client/CodeFirstValidatorRestTemplate.java
+++ /dev/null
@@ -1,118 +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.demo.validator.client;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.servicecomb.core.Const;
-import org.apache.servicecomb.core.CseContext;
-import org.apache.servicecomb.demo.DemoConst;
-import org.apache.servicecomb.demo.TestMgr;
-import org.apache.servicecomb.swagger.invocation.context.ContextUtils;
-import org.apache.servicecomb.swagger.invocation.context.InvocationContext;
-import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.client.RestTemplate;
-
-public class CodeFirstValidatorRestTemplate {
-  protected void changeTransport(String microserviceName, String transport) {
-    CseContext.getInstance().getConsumerProviderManager().setTransport(microserviceName, transport);
-    TestMgr.setMsg(microserviceName, transport);
-  }
-
-  public void testCodeFirst(RestTemplate template, String microserviceName, String basePath) {
-    String cseUrlPrefix = "cse://" + microserviceName + basePath;
-    for (String transport : DemoConst.transports) {
-      changeTransport(microserviceName, transport);
-      testAllTransport(microserviceName, template, cseUrlPrefix);
-    }
-  }
-
-  protected void testAllTransport(String microserviceName, RestTemplate template, String cseUrlPrefix) {
-    testCodeFirstAdd(template, cseUrlPrefix);
-    testCodeFirstAddForException(template, cseUrlPrefix);
-    testCodeFirstSayHi(template, cseUrlPrefix);
-    testCodeFirstSayHiForException(template, cseUrlPrefix);
-    testTraceIdOnContextContainsTraceId(template, cseUrlPrefix);
-  }
-
-  protected void checkStatusCode(String microserviceName, int expectStatusCode, HttpStatus httpStatus) {
-    TestMgr.check(expectStatusCode, httpStatus.value());
-  }
-
-  protected void testCodeFirstSayHi(RestTemplate template, String cseUrlPrefix) {
-    ResponseEntity<String> responseEntity =
-        template.exchange(cseUrlPrefix + "sayhi/{name}", HttpMethod.PUT, null, String.class, "world");
-    TestMgr.check(202, responseEntity.getStatusCode());
-    TestMgr.check("world sayhi", responseEntity.getBody());
-  }
-
-  protected void testCodeFirstSayHiForException(RestTemplate template, String cseUrlPrefix) {
-    boolean isExcep = false;
-    try {
-      template.exchange(cseUrlPrefix + "sayhi/{name}", HttpMethod.PUT, null, String.class, "te");
-    } catch (InvocationException e) {
-      isExcep = true;
-      TestMgr.check(e.getStatus().getStatusCode(), 400);
-    }
-    TestMgr.check(true, isExcep);
-  }
-
-  protected void testCodeFirstAdd(RestTemplate template, String cseUrlPrefix) {
-    Map<String, String> params = new HashMap<>();
-    params.put("a", "5");
-    params.put("b", "20");
-    int result =
-        template.postForObject(cseUrlPrefix + "add", params, Integer.class);
-    TestMgr.check(25, result);
-  }
-
-  protected void testCodeFirstAddForException(RestTemplate template, String cseUrlPrefix) {
-    Map<String, String> params = new HashMap<>();
-    params.put("a", "5");
-    params.put("b", "3");
-    boolean isExcep = false;
-    try {
-      template.postForObject(cseUrlPrefix + "add", params, Integer.class);
-    } catch (InvocationException e) {
-      isExcep = true;
-      TestMgr.check(e.getStatus().getStatusCode(), 400);
-    }
-
-    TestMgr.check(true, isExcep);
-  }
-
-  protected void testTraceIdOnNotSetBefore(RestTemplate template, String cseUrlPrefix) {
-    String traceIdUrl = cseUrlPrefix + "traceId";
-    String result = template.getForObject(traceIdUrl, String.class);
-    TestMgr.checkNotEmpty(result);
-  }
-
-  protected void testTraceIdOnContextContainsTraceId(RestTemplate template, String cseUrlPrefix) {
-    String traceIdUrl = cseUrlPrefix + "traceId";
-    InvocationContext invocationContext = new InvocationContext();
-    invocationContext.addContext(Const.TRACE_ID_NAME, String.valueOf(Long.MIN_VALUE));
-    ContextUtils.setInvocationContext(invocationContext);
-    String result = template.getForObject(traceIdUrl, String.class);
-    TestMgr.check(String.valueOf(Long.MIN_VALUE), result);
-    ContextUtils.removeInvocationContext();
-  }
-}
diff --git a/demo/demo-validator/validator-client/src/main/java/org/apache/servicecomb/demo/validator/client/ValidatorClient.java b/demo/demo-validator/validator-client/src/main/java/org/apache/servicecomb/demo/validator/client/ValidatorClient.java
deleted file mode 100644
index 2f257a1..0000000
--- a/demo/demo-validator/validator-client/src/main/java/org/apache/servicecomb/demo/validator/client/ValidatorClient.java
+++ /dev/null
@@ -1,48 +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.demo.validator.client;
-
-import org.apache.servicecomb.demo.TestMgr;
-import org.apache.servicecomb.foundation.common.utils.BeanUtils;
-import org.apache.servicecomb.foundation.common.utils.Log4jUtils;
-import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
-import org.springframework.web.client.RestTemplate;
-
-public class ValidatorClient {
-  private static RestTemplate templateNew = RestTemplateBuilder.create();
-
-  public static void main(String[] args) throws Exception {
-    init();
-
-    run();
-
-    TestMgr.summary();
-  }
-
-  public static void init() throws Exception {
-    Log4jUtils.init();
-    BeanUtils.init();
-  }
-
-  public static void run() throws Exception {
-    CodeFirstValidatorRestTemplate codeFirstClient = new CodeFirstValidatorRestTemplate();
-    codeFirstClient.testCodeFirst(templateNew, "validator", "/codeFirstJaxrs/");
-  }
-
-
-}
diff --git a/demo/demo-validator/validator-client/src/main/resources/microservice.yaml b/demo/demo-validator/validator-client/src/main/resources/microservice.yaml
deleted file mode 100644
index 8055ff5..0000000
--- a/demo/demo-validator/validator-client/src/main/resources/microservice.yaml
+++ /dev/null
@@ -1,29 +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.
-## ---------------------------------------------------------------------------
-
-APPLICATION_ID: validatortest
-service_description:
-  name: validatorClient
-  version: 0.0.1
-cse:
-  service:
-    registry:
-      address: http://127.0.0.1:30100
-  handler:
-    chain:
-      Consumer:
-        default: bizkeeper-consumer,loadbalance
diff --git a/demo/demo-validator/validator-server/pom.xml b/demo/demo-validator/validator-server/pom.xml
deleted file mode 100644
index 4437cf9..0000000
--- a/demo/demo-validator/validator-server/pom.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-<?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>
-  <parent>
-    <groupId>org.apache.servicecomb.demo</groupId>
-    <artifactId>demo-validator</artifactId>
-    <version>1.0.0-m2-SNAPSHOT</version>
-  </parent>
-  <artifactId>validator-server</artifactId>
-  <name>Java Chassis::Demo::Validator::Server</name>
-  <dependencies>
-    <dependency>
-    <groupId>org.apache.servicecomb.demo</groupId>
-    <artifactId>demo-schema</artifactId>
-    </dependency>
-    <dependency>
-    <groupId>org.apache.servicecomb</groupId>
-    <artifactId>provider-jaxrs</artifactId>
-    </dependency>
-    <dependency>
-    <groupId>org.apache.servicecomb</groupId>
-    <artifactId>swagger-invocation-validator</artifactId>
-    </dependency>
-  </dependencies>
-  <properties>
-    <demo.main>org.apache.servicecomb.demo.validator.server.ValidatorServer</demo.main>
-  </properties>
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-dependency-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>1.0.0-m2-SNAPSHOT</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-validator/validator-server/src/main/resources/microservice.yaml b/demo/demo-validator/validator-server/src/main/resources/microservice.yaml
deleted file mode 100644
index b2711fd..0000000
--- a/demo/demo-validator/validator-server/src/main/resources/microservice.yaml
+++ /dev/null
@@ -1,33 +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.
-## ---------------------------------------------------------------------------
-
-APPLICATION_ID: validatortest
-service_description:
-  name: validator
-  version: 0.0.2
-cse:
-  service:
-    registry:
-      address: http://127.0.0.1:30100
-  rest:
-    address: 0.0.0.0:8080
-  highway:
-    address: 0.0.0.0:7070
-  handler:
-    chain:
-      Provider:
-        default: bizkeeper-provider
diff --git a/demo/pom.xml b/demo/pom.xml
index 465ec97..55505d2 100644
--- a/demo/pom.xml
+++ b/demo/pom.xml
@@ -47,7 +47,6 @@
     <module>demo-multiple</module>
     <module>demo-signature</module>
     <module>demo-edge</module>
-    <module>demo-validator</module>
     <module>perf</module>
   </modules>
 
diff --git a/swagger/swagger-invocation/invocation-validator/pom.xml b/swagger/swagger-invocation/invocation-validator/pom.xml
index b0eb754..08b2c0c 100644
--- a/swagger/swagger-invocation/invocation-validator/pom.xml
+++ b/swagger/swagger-invocation/invocation-validator/pom.xml
@@ -16,39 +16,37 @@
   -->
 
 <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</groupId>
-		<artifactId>swagger-invocation</artifactId>
-		<version>1.0.0-m2-SNAPSHOT</version>
-	</parent>
-	<artifactId>swagger-invocation-validator</artifactId>
-	<name>Java Chassis::Swagger::Invocation::Validator</name>
-
-
-	<dependencies>
-		<dependency>
-			<groupId>org.apache.servicecomb</groupId>
-			<artifactId>swagger-invocation-core</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>org.hibernate</groupId>
-			<artifactId>hibernate-validator</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>org.glassfish</groupId>
-			<artifactId>javax.el</artifactId>
-		</dependency>
-		<dependency>
-			<groupId>org.slf4j</groupId>
-			<artifactId>slf4j-log4j12</artifactId>
-			<scope>test</scope>
-		</dependency>
-		<dependency>
-			<groupId>log4j</groupId>
-			<artifactId>log4j</artifactId>
-			<scope>test</scope>
-		</dependency>
-	</dependencies>
+  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</groupId>
+    <artifactId>swagger-invocation</artifactId>
+    <version>1.0.0-m2-SNAPSHOT</version>
+  </parent>
+  <artifactId>swagger-invocation-validator</artifactId>
+  <name>Java Chassis::Swagger::Invocation::Validator</name>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>swagger-invocation-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.hibernate</groupId>
+      <artifactId>hibernate-validator</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.glassfish</groupId>
+      <artifactId>javax.el</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
 </project>
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
liubao@apache.org.