You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2018/12/24 08:29:23 UTC

[GitHub] wujimin closed pull request #1040: [SCB-928]add some integration tests for this issue

wujimin closed pull request #1040: [SCB-928]add some integration tests for this issue
URL: https://github.com/apache/servicecomb-java-chassis/pull/1040
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/ConsumerMain.java b/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/ConsumerMain.java
index 75f899195..94ffdb852 100644
--- a/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/ConsumerMain.java
+++ b/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/ConsumerMain.java
@@ -122,6 +122,7 @@ private static void runShareTestCases() throws Throwable {
     ITJUnitUtils.run(TestRequestBodySpringMvcSchema.class);
     ITJUnitUtils.run(TestDefaultJsonValueJaxrsSchema.class);
     ITJUnitUtils.run(TestRestController.class);
+    ITJUnitUtils.runWithRest(TestRestController.class);
   }
 
   interface ITTask {
diff --git a/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/TestRestController.java b/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/TestRestController.java
index 722a43913..41b9eef54 100644
--- a/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/TestRestController.java
+++ b/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/TestRestController.java
@@ -17,7 +17,9 @@
 
 package org.apache.servicecomb.it.testcase;
 
+import org.apache.servicecomb.it.extend.engine.GateRestTemplate;
 import org.apache.servicecomb.it.extend.engine.ITSCBRestTemplate;
+import org.apache.servicecomb.it.junit.ITJUnitUtils;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -34,6 +36,9 @@
   private static ITSCBRestTemplate restControllerWithRestSchemaSchemaClient = new ITSCBRestTemplate
       ("RestControllerWithRestSchemaSchema");
 
+  private static GateRestTemplate restControllerSchemaClientEdge = GateRestTemplate
+      .createEdgeRestTemplate("org.apache.servicecomb.it.schema.RestControllerSchema");
+
   @Test
   public void restControllerSchemaClient() {
     Assert.assertEquals("/", restControllerSchemaClient.getBasePath());
@@ -41,6 +46,33 @@ public void restControllerSchemaClient() {
     Assert.assertEquals(2, result);
   }
 
+  @Test
+  public void restControllerSchemaClientRestControllerSchemaQueries() {
+    if ("rest".equals(ITJUnitUtils.getTransport())) {
+      System.out.println("restControllerSchemaClientRestControllerSchemaQueries run with REST.");
+      String result = restControllerSchemaClient.getForObject("/v1/restControllerSchemaQueries?a=2", String.class);
+      Assert.assertEquals("/v1/restControllerSchemaQueries?a=2", result);
+      result = restControllerSchemaClient.getForObject("/v1/restControllerSchemaQueries?a=2&b=3", String.class);
+      Assert.assertEquals("/v1/restControllerSchemaQueries?a=2&b=3", result);
+      result = restControllerSchemaClient.getForObject("/v1/restControllerSchemaQueries?a=2&b=3&c=4", String.class);
+      Assert.assertEquals("/v1/restControllerSchemaQueries?a=2&b=3&c=4", result);
+      result = restControllerSchemaClient.getForObject("/v1/restControllerSchemaQueries?a=2&&&", String.class);
+      Assert.assertEquals("/v1/restControllerSchemaQueries?a=2", result);
+
+      System.out.println("restControllerSchemaClientRestControllerSchemaQueries run with REST edge.");
+      result = restControllerSchemaClientEdge.getForObject("/v1/restControllerSchemaQueries?a=2", String.class);
+      Assert.assertEquals("/v1/restControllerSchemaQueries?a=2", result);
+      result = restControllerSchemaClientEdge.getForObject("/v1/restControllerSchemaQueries?b=3", String.class);
+      Assert.assertEquals("/v1/restControllerSchemaQueries?b=3", result);
+      result = restControllerSchemaClientEdge.getForObject("/v1/restControllerSchemaQueries?a=2&b=3&c=4", String.class);
+      Assert.assertEquals("/v1/restControllerSchemaQueries?a=2&b=3&c=4", result);
+      result = restControllerSchemaClientEdge.getForObject("/v1/restControllerSchemaQueries?a=2&&&", String.class);
+      Assert.assertEquals("/v1/restControllerSchemaQueries?a=2", result);
+    } else {
+      System.out.println("restControllerSchemaClientRestControllerSchemaQueries not run with." + ITJUnitUtils.getTransport());
+    }
+  }
+
   @Test
   public void restControllerEmptyMappingSchemaClient() {
     // empty path default to class name(@RequestMapping(path = "")). Shall we change this behavior in future?
diff --git a/integration-tests/it-edge/src/main/resources/microservice.yaml b/integration-tests/it-edge/src/main/resources/microservice.yaml
index 0d49d44a1..aae0bc174 100644
--- a/integration-tests/it-edge/src/main/resources/microservice.yaml
+++ b/integration-tests/it-edge/src/main/resources/microservice.yaml
@@ -47,6 +47,9 @@ servicecomb:
           transport: rest
         queryInput:
           transport: rest
+      org.apache.servicecomb.it.schema.RestControllerSchema:
+        restControllerSchemaQueries:
+          transport: rest
     it-producer-h2:
       generic:
         genericUser:
@@ -61,6 +64,9 @@ servicecomb:
           transport: rest
         queryInput:
           transport: rest
+      org.apache.servicecomb.it.schema.RestControllerSchema:
+        restControllerSchemaQueries:
+          transport: rest
     it-producer-h2c:
       generic:
         genericUser:
@@ -75,6 +81,9 @@ servicecomb:
           transport: rest
         queryInput:
           transport: rest
+      org.apache.servicecomb.it.schema.RestControllerSchema:
+        restControllerSchemaQueries:
+          transport: rest
     it-producer-deploy-springboot2-servlet:
       generic:
         genericUser:
@@ -89,6 +98,9 @@ servicecomb:
           transport: rest
         queryInput:
           transport: rest
+      org.apache.servicecomb.it.schema.RestControllerSchema:
+        restControllerSchemaQueries:
+          transport: rest
     it-producer-deploy-springboot2-standalone:
       generic:
         genericUser:
@@ -103,6 +115,9 @@ servicecomb:
           transport: rest
         queryInput:
           transport: rest
+      org.apache.servicecomb.it.schema.RestControllerSchema:
+        restControllerSchemaQueries:
+          transport: rest
   http:
     dispatcher:
       edge:
diff --git a/integration-tests/it-producer/src/main/java/org/apache/servicecomb/it/schema/RestControllerSchema.java b/integration-tests/it-producer/src/main/java/org/apache/servicecomb/it/schema/RestControllerSchema.java
index 08c6b9861..db39c14d6 100644
--- a/integration-tests/it-producer/src/main/java/org/apache/servicecomb/it/schema/RestControllerSchema.java
+++ b/integration-tests/it-producer/src/main/java/org/apache/servicecomb/it/schema/RestControllerSchema.java
@@ -16,6 +16,8 @@
  */
 package org.apache.servicecomb.it.schema;
 
+import javax.servlet.http.HttpServletRequest;
+
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
@@ -26,4 +28,11 @@
   public int intQuery(@RequestParam(name = "input", required = false, defaultValue = "13") int input) {
     return input;
   }
+
+  @GetMapping(path = "/v1/restControllerSchemaQueries")
+  public String restControllerSchemaQueries(@RequestParam(name = "a", required = false) String a,
+      @RequestParam(name = "b", required = false) String b,
+      @RequestParam(name = "c", required = false) String c, HttpServletRequest request) {
+    return request.getRequestURI() + "?" + request.getQueryString();
+  }
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services