This is an automated email from the ASF dual-hosted git repository.
wujimin 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 ecbc1b8 [SCB-928]add some integration tests for this issue
ecbc1b8 is described below
commit ecbc1b83b6c0ed36eb1329f4199dac1b715021e9
Author: liubao <[email protected]>
AuthorDate: Wed Dec 19 22:16:58 2018 +0800
[SCB-928]add some integration tests for this issue
---
.../org/apache/servicecomb/it/ConsumerMain.java | 1 +
.../it/testcase/TestRestController.java | 32 ++++++++++++++++++++++
.../it-edge/src/main/resources/microservice.yaml | 15 ++++++++++
.../it/schema/RestControllerSchema.java | 9 ++++++
4 files changed, 57 insertions(+)
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 75f8991..94ffdb8 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 @@ public class ConsumerMain {
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 722a439..41b9eef 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 @@ public class TestRestController {
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());
@@ -42,6 +47,33 @@ public class TestRestController {
}
@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?
Assert.assertEquals("/RestControllerEmptyMappingSchema",
restControllerEmptyMappingSchemaClient.getBasePath());
diff --git a/integration-tests/it-edge/src/main/resources/microservice.yaml
b/integration-tests/it-edge/src/main/resources/microservice.yaml
index 0d49d44..aae0bc1 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 08c6b98..db39c14 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 class RestControllerSchema {
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();
+ }
}