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/09/12 01:40:55 UTC
[incubator-servicecomb-java-chassis] branch master updated (ab12d33
-> b88dffb)
This is an automated email from the ASF dual-hosted git repository.
liubao pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git.
from ab12d33 [SCB-841] move string type test case from demo to integration-test
new 41441e9 [SCB-903]Add a feature to serialize/deserialize using Object to avoid information lose
new b68af31 [SCB-903]testing can not start/stop well in docker and will cause testing fail
new ff58e9f [SCB-903]add comments to configurations usage and make testing logic simpler not try 3 times
new b88dffb [SCB-903]rename parameter name
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../rest/codec/param/BodyProcessorCreator.java | 12 +++
.../rest/codec/param/QueryProcessorCreator.java | 6 +-
.../org/apache/servicecomb/core/Invocation.java | 3 +
.../servicecomb/core/definition/OperationMeta.java | 12 +++
.../it-common/src/main/resources/microservice.yaml | 5 +
.../org/apache/servicecomb/it/ConsumerMain.java | 3 +
.../testcase/TestDefaultJsonValueJaxrsSchema.java | 102 +++++++++++++++++++++
.../it-edge/src/main/resources/microservice.yaml | 13 +++
...chema.java => DefaultJsonValueJaxrsSchema.java} | 28 ++++--
.../it/schema/DefaultJsonValueRequest.java | 34 ++++---
.../it/schema/DefaultJsonValueResponse.java | 21 ++---
11 files changed, 207 insertions(+), 32 deletions(-)
create mode 100644 integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/TestDefaultJsonValueJaxrsSchema.java
copy integration-tests/it-producer/src/main/java/org/apache/servicecomb/it/schema/{TransportJaxrsSchema.java => DefaultJsonValueJaxrsSchema.java} (55%)
copy common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/param/AbstractParamProcessor.java => integration-tests/it-producer/src/main/java/org/apache/servicecomb/it/schema/DefaultJsonValueRequest.java (61%)
copy demo/demo-schema/src/main/java/org/apache/servicecomb/demo/multiErrorCode/MultiRequest.java => integration-tests/it-producer/src/main/java/org/apache/servicecomb/it/schema/DefaultJsonValueResponse.java (82%)
[incubator-servicecomb-java-chassis] 01/04: [SCB-903]Add a feature
to serialize/deserialize using Object to avoid information lose
Posted by li...@apache.org.
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 41441e9fe07f5605c80c14a34885b3f76ecef5b6
Author: liubao <ba...@huawei.com>
AuthorDate: Tue Sep 11 15:02:07 2018 +0800
[SCB-903]Add a feature to serialize/deserialize using Object to avoid information lose
---
.../rest/codec/param/BodyProcessorCreator.java | 11 +++
.../rest/codec/param/QueryProcessorCreator.java | 4 +-
.../org/apache/servicecomb/core/Invocation.java | 3 +
.../servicecomb/core/definition/OperationMeta.java | 12 +++
.../it-common/src/main/resources/microservice.yaml | 5 +
.../org/apache/servicecomb/it/ConsumerMain.java | 5 +
.../testcase/TestDefaultJsonValueJaxrsSchema.java | 102 +++++++++++++++++++++
.../it-edge/src/main/resources/microservice.yaml | 13 +++
.../it/schema/DefaultJsonValueJaxrsSchema.java | 47 ++++++++++
.../it/schema/DefaultJsonValueRequest.java | 52 +++++++++++
.../it/schema/DefaultJsonValueResponse.java | 39 ++++++++
11 files changed, 292 insertions(+), 1 deletion(-)
diff --git a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/param/BodyProcessorCreator.java b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/param/BodyProcessorCreator.java
index 18e5bcf..6ee49d0 100644
--- a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/param/BodyProcessorCreator.java
+++ b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/param/BodyProcessorCreator.java
@@ -38,7 +38,9 @@ import org.springframework.util.StringUtils;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
+import com.fasterxml.jackson.databind.type.SimpleType;
import com.fasterxml.jackson.databind.type.TypeFactory;
+import com.netflix.config.DynamicPropertyFactory;
import io.swagger.models.parameters.Parameter;
import io.vertx.core.buffer.Buffer;
@@ -49,6 +51,11 @@ public class BodyProcessorCreator implements ParamValueProcessorCreator {
public static final String PARAMTYPE = "body";
+ private static final JavaType OBJECT_TYPE = SimpleType.constructUnsafe(Object.class);
+
+ private static boolean decodeAsObject = DynamicPropertyFactory.getInstance()
+ .getBooleanProperty("servicecomb.rest.parameter.decodeAsObject", false).get();
+
public static class BodyProcessor implements ParamValueProcessor {
protected JavaType targetType;
@@ -88,6 +95,10 @@ public class BodyProcessorCreator implements ParamValueProcessorCreator {
}
try {
+ if (decodeAsObject) {
+ return RestObjectMapperFactory.getRestObjectMapper()
+ .readValue(inputStream, OBJECT_TYPE);
+ }
return RestObjectMapperFactory.getRestObjectMapper()
.readValue(inputStream, targetType);
} catch (MismatchedInputException e) {
diff --git a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/param/QueryProcessorCreator.java b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/param/QueryProcessorCreator.java
index 124e178..6983a39 100644
--- a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/param/QueryProcessorCreator.java
+++ b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/param/QueryProcessorCreator.java
@@ -37,6 +37,8 @@ public class QueryProcessorCreator implements ParamValueProcessorCreator {
public static class QueryProcessor extends AbstractParamProcessor {
private boolean emptyAsNull = DynamicPropertyFactory.getInstance()
.getBooleanProperty("servicecomb.rest.parameter.query.emptyAsNull", false).get();
+ private boolean ignoreDefaultValue = DynamicPropertyFactory.getInstance()
+ .getBooleanProperty("servicecomb.rest.parameter.query.ignoreDefaultValue", false).get();
public QueryProcessor(String paramPath, JavaType targetType, Object defaultValue) {
super(paramPath, targetType, defaultValue);
@@ -57,7 +59,7 @@ public class QueryProcessorCreator implements ParamValueProcessorCreator {
}
if (value == null) {
Object defaultValue = getDefaultValue();
- if (defaultValue != null) {
+ if (!ignoreDefaultValue && defaultValue != null) {
value = defaultValue;
}
}
diff --git a/core/src/main/java/org/apache/servicecomb/core/Invocation.java b/core/src/main/java/org/apache/servicecomb/core/Invocation.java
index ceb5f92..eede665 100644
--- a/core/src/main/java/org/apache/servicecomb/core/Invocation.java
+++ b/core/src/main/java/org/apache/servicecomb/core/Invocation.java
@@ -185,6 +185,9 @@ public class Invocation extends SwaggerInvocation {
}
public String getConfigTransportName() {
+ if (operationMeta.getPreferredTransport() != null) {
+ return operationMeta.getPreferredTransport();
+ }
return referenceConfig.getTransport();
}
diff --git a/core/src/main/java/org/apache/servicecomb/core/definition/OperationMeta.java b/core/src/main/java/org/apache/servicecomb/core/definition/OperationMeta.java
index a188275..906227a 100644
--- a/core/src/main/java/org/apache/servicecomb/core/definition/OperationMeta.java
+++ b/core/src/main/java/org/apache/servicecomb/core/definition/OperationMeta.java
@@ -27,6 +27,8 @@ import org.apache.servicecomb.core.executor.ExecutorManager;
import org.apache.servicecomb.swagger.invocation.response.ResponseMeta;
import org.apache.servicecomb.swagger.invocation.response.ResponsesMeta;
+import com.netflix.config.DynamicPropertyFactory;
+
import io.swagger.models.Operation;
public class OperationMeta {
@@ -56,6 +58,8 @@ public class OperationMeta {
// 为避免每个地方都做复杂的层次管理,直接在这里保存扩展数据
private Map<String, Object> extData = new ConcurrentHashMap<>();
+ private String preferredTransport = null;
+
public void init(SchemaMeta schemaMeta, Method method, String operationPath, String httpMethod,
Operation swaggerOperation) {
this.schemaMeta = schemaMeta;
@@ -71,6 +75,14 @@ public class OperationMeta {
responsesMeta.init(schemaMeta.getSwaggerToClassGenerator(),
swaggerOperation,
method.getGenericReturnType());
+
+ preferredTransport = DynamicPropertyFactory.getInstance()
+ .getStringProperty("servicecomb.operation."
+ + microserviceQualifiedName + ".preferredTransport", null).get();
+ }
+
+ public String getPreferredTransport() {
+ return preferredTransport;
}
public String getHttpMethod() {
diff --git a/integration-tests/it-common/src/main/resources/microservice.yaml b/integration-tests/it-common/src/main/resources/microservice.yaml
index d4a11c7..43df9e2 100644
--- a/integration-tests/it-common/src/main/resources/microservice.yaml
+++ b/integration-tests/it-common/src/main/resources/microservice.yaml
@@ -21,10 +21,15 @@ APPLICATION_ID: integration-test
service_description:
name: $invalid-name-must-be-overridden
version: 1.0.0
+ environment: development
servicecomb:
service:
registry:
address: http://127.0.0.1:30100
+ instance:
+ healthCheck:
+ interval: 5
+ times: 3
request:
# 10 minute
timeout: 600000
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 a3b7704..0490f35 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
@@ -22,6 +22,7 @@ import org.apache.servicecomb.it.deploy.Deploys;
import org.apache.servicecomb.it.junit.ITJUnitUtils;
import org.apache.servicecomb.it.testcase.TestChangeTransport;
import org.apache.servicecomb.it.testcase.TestDataTypePrimitive;
+import org.apache.servicecomb.it.testcase.TestDefaultJsonValueJaxrsSchema;
import org.apache.servicecomb.it.testcase.TestDefaultValue;
import org.apache.servicecomb.it.testcase.TestIgnoreMethod;
import org.apache.servicecomb.it.testcase.TestParamCodec;
@@ -44,6 +45,9 @@ public class ConsumerMain {
BeanUtils.init();
ITUtils.waitBootFinished();
+ // run 3 times to test transport choosing.
+ run();
+ run();
run();
SCBEngine.getInstance().destroy();
@@ -113,6 +117,7 @@ public class ConsumerMain {
ITJUnitUtils.runWithHighwayAndRest(TestParamCodec.class);
ITJUnitUtils.run(TestParamCodecEdge.class);
+ ITJUnitUtils.run(TestDefaultJsonValueJaxrsSchema.class);
ITJUnitUtils.runWithRest(TestRestServerConfig.class);
diff --git a/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/TestDefaultJsonValueJaxrsSchema.java b/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/TestDefaultJsonValueJaxrsSchema.java
new file mode 100644
index 0000000..0754532
--- /dev/null
+++ b/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/TestDefaultJsonValueJaxrsSchema.java
@@ -0,0 +1,102 @@
+/*
+ * 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.it.testcase;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.servicecomb.it.extend.engine.GateRestTemplate;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.web.client.RestTemplate;
+
+public class TestDefaultJsonValueJaxrsSchema {
+ static RestTemplate client = GateRestTemplate.createEdgeRestTemplate("defaultJsonValueJaxrs");
+
+ @BeforeClass
+ public static void classSetup() {
+ }
+
+ @Test
+ public void invokeFromEdgeWithQuery() {
+ String result = client.getForObject("/queryInput?size=3", String.class);
+ Assert.assertEquals(result, "expected:3:3");
+
+ result = client.getForObject("/queryInput", String.class);
+ Assert.assertEquals(result, "expected:0:null");
+
+ result = client.getForObject("/queryInput?size=", String.class);
+ Assert.assertEquals(result, "expected:0:null");
+ }
+
+ @Test
+ public void invokeFromEdgeWithRawJson() {
+ HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ Map<String, Object> body = new HashMap<>();
+ body.put("type", 100);
+ HttpEntity<Map<String, Object>> entity = new HttpEntity<>(body, headers);
+ Map result =
+ client.postForObject("/jsonInput", entity, Map.class);
+ Assert.assertEquals(result.get("type"), 100);
+ Assert.assertEquals(result.get("message"), "expected:30:0");
+
+ body = new HashMap<>();
+ body.put("type", 100);
+ body.put("defaultValue", null);
+ entity = new HttpEntity<>(body, headers);
+ result =
+ client.postForObject("/jsonInput", entity, Map.class);
+ Assert.assertEquals(result.get("type"), 100);
+ Assert.assertEquals(result.get("message"), "expected:null:0");
+
+ body = new HashMap<>();
+ body.put("type", 200);
+ body.put("defaultValue", -1);
+ entity = new HttpEntity<>(body, headers);
+ result =
+ client.postForObject("/jsonInput", entity, Map.class);
+ Assert.assertEquals(result.get("type"), 200);
+ Assert.assertEquals(result.get("message"), "expected:-1:0");
+
+ body = new HashMap<>();
+ body.put("type", 200);
+ body.put("defaultValue", -1);
+ body.put("items", null);
+ entity = new HttpEntity<>(body, headers);
+ result =
+ client.postForObject("/jsonInput", entity, Map.class);
+ Assert.assertEquals(result.get("type"), 200);
+ Assert.assertEquals(result.get("message"), "expected:-1:null");
+
+ body = new HashMap<>();
+ body.put("type", 200);
+ body.put("defaultValue", -1);
+ body.put("items", new ArrayList<String>());
+ entity = new HttpEntity<>(body, headers);
+ result =
+ client.postForObject("/jsonInput", entity, Map.class);
+ Assert.assertEquals(result.get("type"), 200);
+ Assert.assertEquals(result.get("message"), "expected:-1:0");
+ }
+}
diff --git a/integration-tests/it-edge/src/main/resources/microservice.yaml b/integration-tests/it-edge/src/main/resources/microservice.yaml
index b1ca0db..3f20b31 100644
--- a/integration-tests/it-edge/src/main/resources/microservice.yaml
+++ b/integration-tests/it-edge/src/main/resources/microservice.yaml
@@ -25,6 +25,19 @@ servicecomb:
default: loadbalance
service:
it-auth: loadbalance
+ rest:
+ parameter:
+ decodeAsObject: true
+ query:
+ ignoreDefaultValue: true
+ emptyAsNull: true
+ operation:
+ it-producer:
+ defaultJsonValueJaxrs:
+ jsonInput:
+ preferredTransport: rest
+ queryInput:
+ preferredTransport: rest
http:
dispatcher:
edge:
diff --git a/integration-tests/it-producer/src/main/java/org/apache/servicecomb/it/schema/DefaultJsonValueJaxrsSchema.java b/integration-tests/it-producer/src/main/java/org/apache/servicecomb/it/schema/DefaultJsonValueJaxrsSchema.java
new file mode 100644
index 0000000..6530853
--- /dev/null
+++ b/integration-tests/it-producer/src/main/java/org/apache/servicecomb/it/schema/DefaultJsonValueJaxrsSchema.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.it.schema;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+
+@RestSchema(schemaId = "defaultJsonValueJaxrs")
+@Path("/v1/defaultJsonValueJaxrs")
+public class DefaultJsonValueJaxrsSchema {
+ @Path("jsonInput")
+ @POST
+ public DefaultJsonValueResponse jsonInput(DefaultJsonValueRequest request) {
+ DefaultJsonValueResponse response = new DefaultJsonValueResponse();
+ response.setType(request.getType());
+ StringBuilder sb = new StringBuilder();
+ sb.append(request.getDefaultValue());
+ response.setMessage("expected:" + sb.toString() + ":" + (request.getItems() == null ? null
+ : request.getItems().size()));
+ return response;
+ }
+
+ @Path("queryInput")
+ @GET
+ public String queryInput(HttpServletRequest request, @QueryParam("size") int size) {
+ return "expected:" + size + ":" + request.getParameter("size");
+ }
+}
diff --git a/integration-tests/it-producer/src/main/java/org/apache/servicecomb/it/schema/DefaultJsonValueRequest.java b/integration-tests/it-producer/src/main/java/org/apache/servicecomb/it/schema/DefaultJsonValueRequest.java
new file mode 100644
index 0000000..3410eac
--- /dev/null
+++ b/integration-tests/it-producer/src/main/java/org/apache/servicecomb/it/schema/DefaultJsonValueRequest.java
@@ -0,0 +1,52 @@
+/*
+ * 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.it.schema;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class DefaultJsonValueRequest {
+ private int type;
+
+ private Integer defaultValue = 30;
+
+ private List<String> items = new ArrayList<>();
+
+ public int getType() {
+ return type;
+ }
+
+ public void setType(int type) {
+ this.type = type;
+ }
+
+ public Integer getDefaultValue() {
+ return defaultValue;
+ }
+
+ public void setDefaultValue(Integer defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ public List<String> getItems() {
+ return items;
+ }
+
+ public void setItems(List<String> items) {
+ this.items = items;
+ }
+}
diff --git a/integration-tests/it-producer/src/main/java/org/apache/servicecomb/it/schema/DefaultJsonValueResponse.java b/integration-tests/it-producer/src/main/java/org/apache/servicecomb/it/schema/DefaultJsonValueResponse.java
new file mode 100644
index 0000000..69079ea
--- /dev/null
+++ b/integration-tests/it-producer/src/main/java/org/apache/servicecomb/it/schema/DefaultJsonValueResponse.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.it.schema;
+
+public class DefaultJsonValueResponse {
+ private int type;
+
+ private String message;
+
+ public int getType() {
+ return type;
+ }
+
+ public void setType(int type) {
+ this.type = type;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+}
[incubator-servicecomb-java-chassis] 04/04: [SCB-903]rename
parameter name
Posted by li...@apache.org.
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 b88dffbcd0b1c3a9cf31442b0ef25ef4cd7de28e
Author: liubao <ba...@huawei.com>
AuthorDate: Wed Sep 12 09:16:34 2018 +0800
[SCB-903]rename parameter name
---
core/src/main/java/org/apache/servicecomb/core/Invocation.java | 4 ++--
.../org/apache/servicecomb/core/definition/OperationMeta.java | 10 +++++-----
integration-tests/it-edge/src/main/resources/microservice.yaml | 4 ++--
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/core/src/main/java/org/apache/servicecomb/core/Invocation.java b/core/src/main/java/org/apache/servicecomb/core/Invocation.java
index eede665..43dc36b 100644
--- a/core/src/main/java/org/apache/servicecomb/core/Invocation.java
+++ b/core/src/main/java/org/apache/servicecomb/core/Invocation.java
@@ -185,8 +185,8 @@ public class Invocation extends SwaggerInvocation {
}
public String getConfigTransportName() {
- if (operationMeta.getPreferredTransport() != null) {
- return operationMeta.getPreferredTransport();
+ if (operationMeta.getTransport() != null) {
+ return operationMeta.getTransport();
}
return referenceConfig.getTransport();
}
diff --git a/core/src/main/java/org/apache/servicecomb/core/definition/OperationMeta.java b/core/src/main/java/org/apache/servicecomb/core/definition/OperationMeta.java
index 906227a..4e34716 100644
--- a/core/src/main/java/org/apache/servicecomb/core/definition/OperationMeta.java
+++ b/core/src/main/java/org/apache/servicecomb/core/definition/OperationMeta.java
@@ -58,7 +58,7 @@ public class OperationMeta {
// 为避免每个地方都做复杂的层次管理,直接在这里保存扩展数据
private Map<String, Object> extData = new ConcurrentHashMap<>();
- private String preferredTransport = null;
+ private String transport = null;
public void init(SchemaMeta schemaMeta, Method method, String operationPath, String httpMethod,
Operation swaggerOperation) {
@@ -76,13 +76,13 @@ public class OperationMeta {
swaggerOperation,
method.getGenericReturnType());
- preferredTransport = DynamicPropertyFactory.getInstance()
+ transport = DynamicPropertyFactory.getInstance()
.getStringProperty("servicecomb.operation."
- + microserviceQualifiedName + ".preferredTransport", null).get();
+ + microserviceQualifiedName + ".transport", null).get();
}
- public String getPreferredTransport() {
- return preferredTransport;
+ public String getTransport() {
+ return transport;
}
public String getHttpMethod() {
diff --git a/integration-tests/it-edge/src/main/resources/microservice.yaml b/integration-tests/it-edge/src/main/resources/microservice.yaml
index 3f20b31..88703c0 100644
--- a/integration-tests/it-edge/src/main/resources/microservice.yaml
+++ b/integration-tests/it-edge/src/main/resources/microservice.yaml
@@ -35,9 +35,9 @@ servicecomb:
it-producer:
defaultJsonValueJaxrs:
jsonInput:
- preferredTransport: rest
+ transport: rest
queryInput:
- preferredTransport: rest
+ transport: rest
http:
dispatcher:
edge:
[incubator-servicecomb-java-chassis] 03/04: [SCB-903]add comments
to configurations usage and make testing logic simpler not try 3 times
Posted by li...@apache.org.
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 ff58e9f5e8cfffa53f2cacb3d9da0a7688eed264
Author: liubao <ba...@huawei.com>
AuthorDate: Tue Sep 11 17:58:01 2018 +0800
[SCB-903]add comments to configurations usage and make testing logic simpler not try 3 times
---
.../rest/codec/param/BodyProcessorCreator.java | 1 +
.../rest/codec/param/QueryProcessorCreator.java | 2 ++
.../org/apache/servicecomb/it/ConsumerMain.java | 25 +++++++++++-----------
3 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/param/BodyProcessorCreator.java b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/param/BodyProcessorCreator.java
index 6ee49d0..2969744 100644
--- a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/param/BodyProcessorCreator.java
+++ b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/param/BodyProcessorCreator.java
@@ -53,6 +53,7 @@ public class BodyProcessorCreator implements ParamValueProcessorCreator {
private static final JavaType OBJECT_TYPE = SimpleType.constructUnsafe(Object.class);
+ // This configuration is used for temporary use only. Do not use it if you are sure how it works. And may be deleted in future.
private static boolean decodeAsObject = DynamicPropertyFactory.getInstance()
.getBooleanProperty("servicecomb.rest.parameter.decodeAsObject", false).get();
diff --git a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/param/QueryProcessorCreator.java b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/param/QueryProcessorCreator.java
index 6983a39..713711e 100644
--- a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/param/QueryProcessorCreator.java
+++ b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/param/QueryProcessorCreator.java
@@ -35,8 +35,10 @@ public class QueryProcessorCreator implements ParamValueProcessorCreator {
public static final String PARAMTYPE = "query";
public static class QueryProcessor extends AbstractParamProcessor {
+ // This configuration is used for temporary use only. Do not use it if you are sure how it works. And may be deleted in future.
private boolean emptyAsNull = DynamicPropertyFactory.getInstance()
.getBooleanProperty("servicecomb.rest.parameter.query.emptyAsNull", false).get();
+ // This configuration is used for temporary use only. Do not use it if you are sure how it works. And may be deleted in future.
private boolean ignoreDefaultValue = DynamicPropertyFactory.getInstance()
.getBooleanProperty("servicecomb.rest.parameter.query.ignoreDefaultValue", false).get();
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 a0b505a..8177191 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
@@ -103,23 +103,22 @@ public class ConsumerMain {
deploys.getBaseProducer().ensureReady();
ITJUnitUtils.addParent("standalone");
- // run 3 times to test transport choose
- for(int i=0; i < 3; i++) {
- ITJUnitUtils.runWithHighwayAndRest(TestChangeTransport.class);
- ITJUnitUtils.runWithHighwayAndRest(TestDataTypePrimitive.class);
- // only rest support default value feature
- ITJUnitUtils.runWithRest(TestDefaultValue.class);
+ ITJUnitUtils.runWithHighwayAndRest(TestChangeTransport.class);
+ ITJUnitUtils.runWithHighwayAndRest(TestDataTypePrimitive.class);
- ITJUnitUtils.runWithHighwayAndRest(TestTrace.class);
- ITJUnitUtils.run(TestTraceEdge.class);
+ // only rest support default value feature
+ ITJUnitUtils.runWithRest(TestDefaultValue.class);
- ITJUnitUtils.runWithHighwayAndRest(TestParamCodec.class);
- ITJUnitUtils.run(TestParamCodecEdge.class);
- ITJUnitUtils.run(TestDefaultJsonValueJaxrsSchema.class);
+ ITJUnitUtils.runWithHighwayAndRest(TestTrace.class);
+ ITJUnitUtils.run(TestTraceEdge.class);
+
+ ITJUnitUtils.runWithHighwayAndRest(TestParamCodec.class);
+ ITJUnitUtils.run(TestParamCodecEdge.class);
+ ITJUnitUtils.run(TestDefaultJsonValueJaxrsSchema.class);
+
+ ITJUnitUtils.runWithRest(TestRestServerConfig.class);
- ITJUnitUtils.runWithRest(TestRestServerConfig.class);
- }
ITJUnitUtils.getParents().pop();
deploys.getBaseProducer().stop();
}
[incubator-servicecomb-java-chassis] 02/04: [SCB-903]testing can
not start/stop well in docker and will cause testing fail
Posted by li...@apache.org.
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 b68af31f9c35c302799e3a8d8acfb9685d890d6a
Author: liubao <ba...@huawei.com>
AuthorDate: Tue Sep 11 16:33:27 2018 +0800
[SCB-903]testing can not start/stop well in docker and will cause testing fail
---
.../org/apache/servicecomb/it/ConsumerMain.java | 29 +++++++++++-----------
1 file changed, 14 insertions(+), 15 deletions(-)
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 0490f35..a0b505a 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
@@ -45,9 +45,6 @@ public class ConsumerMain {
BeanUtils.init();
ITUtils.waitBootFinished();
- // run 3 times to test transport choosing.
- run();
- run();
run();
SCBEngine.getInstance().destroy();
@@ -104,23 +101,25 @@ public class ConsumerMain {
private static void testStandalone() throws Throwable {
deploys.getBaseProducer().ensureReady();
- ITJUnitUtils.addParent("standalone");
- ITJUnitUtils.runWithHighwayAndRest(TestChangeTransport.class);
- ITJUnitUtils.runWithHighwayAndRest(TestDataTypePrimitive.class);
-
- // only rest support default value feature
- ITJUnitUtils.runWithRest(TestDefaultValue.class);
+ ITJUnitUtils.addParent("standalone");
+ // run 3 times to test transport choose
+ for(int i=0; i < 3; i++) {
+ ITJUnitUtils.runWithHighwayAndRest(TestChangeTransport.class);
+ ITJUnitUtils.runWithHighwayAndRest(TestDataTypePrimitive.class);
- ITJUnitUtils.runWithHighwayAndRest(TestTrace.class);
- ITJUnitUtils.run(TestTraceEdge.class);
+ // only rest support default value feature
+ ITJUnitUtils.runWithRest(TestDefaultValue.class);
- ITJUnitUtils.runWithHighwayAndRest(TestParamCodec.class);
- ITJUnitUtils.run(TestParamCodecEdge.class);
- ITJUnitUtils.run(TestDefaultJsonValueJaxrsSchema.class);
+ ITJUnitUtils.runWithHighwayAndRest(TestTrace.class);
+ ITJUnitUtils.run(TestTraceEdge.class);
- ITJUnitUtils.runWithRest(TestRestServerConfig.class);
+ ITJUnitUtils.runWithHighwayAndRest(TestParamCodec.class);
+ ITJUnitUtils.run(TestParamCodecEdge.class);
+ ITJUnitUtils.run(TestDefaultJsonValueJaxrsSchema.class);
+ ITJUnitUtils.runWithRest(TestRestServerConfig.class);
+ }
ITJUnitUtils.getParents().pop();
deploys.getBaseProducer().stop();
}