[GitHub] [servicecomb-java-chassis] new-lcc opened a new issue #1262: 一键式脚手架 现在打不开了?
new-lcc opened a new issue #1262: 一键式脚手架 现在打不开了? URL: https://github.com/apache/servicecomb-java-chassis/issues/1262 一键式脚手架 现在打不开了? http://start.servicecomb.io/ This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [servicecomb-pack] coveralls commented on issue #489: Fix typo on ParametersContext class
coveralls commented on issue #489: Fix typo on ParametersContext class URL: https://github.com/apache/servicecomb-pack/pull/489#issuecomment-508433171 [![Coverage Status](https://coveralls.io/builds/24368688/badge)](https://coveralls.io/builds/24368688) Coverage decreased (-0.2%) to 89.156% when pulling **66d59dcb796b8ab37217b491690609f8a0767c11 on chanjarster:fixtypo** into **bcf978dfc1bde47a97e2591bd20e34ca78034f50 on apache:master**. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [servicecomb-java-chassis] liubao68 merged pull request #1260: [SCB-1347[WIP][WEAK] tiny optimize for DefaultParameterNameProvider
liubao68 merged pull request #1260: [SCB-1347[WIP][WEAK] tiny optimize for DefaultParameterNameProvider URL: https://github.com/apache/servicecomb-java-chassis/pull/1260 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[servicecomb-java-chassis] branch weak-contract-type updated: [SCB-1347[WIP][WEAK] tiny optimize for DefaultParameterNameProvider
This is an automated email from the ASF dual-hosted git repository. liubao pushed a commit to branch weak-contract-type in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git The following commit(s) were added to refs/heads/weak-contract-type by this push: new 1740ce9 [SCB-1347[WIP][WEAK] tiny optimize for DefaultParameterNameProvider 1740ce9 is described below commit 1740ce95868d7981c2ac4c8587be0e96e9339e99 Author: wujimin AuthorDate: Wed Jul 3 23:25:30 2019 +0800 [SCB-1347[WIP][WEAK] tiny optimize for DefaultParameterNameProvider --- .../validator/DefaultParameterNameProvider.java | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/swagger/swagger-invocation/invocation-validator/src/main/java/org/apache/servicecomb/swagger/invocation/validator/DefaultParameterNameProvider.java b/swagger/swagger-invocation/invocation-validator/src/main/java/org/apache/servicecomb/swagger/invocation/validator/DefaultParameterNameProvider.java index 0188b67..09f78b2 100644 --- a/swagger/swagger-invocation/invocation-validator/src/main/java/org/apache/servicecomb/swagger/invocation/validator/DefaultParameterNameProvider.java +++ b/swagger/swagger-invocation/invocation-validator/src/main/java/org/apache/servicecomb/swagger/invocation/validator/DefaultParameterNameProvider.java @@ -20,15 +20,15 @@ import java.lang.reflect.AccessibleObject; import java.lang.reflect.Constructor; import java.lang.reflect.Executable; import java.lang.reflect.Method; +import java.lang.reflect.Parameter; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; + import javax.validation.ParameterNameProvider; import org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx; -import org.apache.servicecomb.swagger.generator.core.utils.ParamUtils; - public class DefaultParameterNameProvider implements ParameterNameProvider { private final Map> methodCache = new ConcurrentHashMapEx<>(); @@ -44,11 +44,12 @@ public class DefaultParameterNameProvider implements ParameterNameProvider { } private List getParameterNamesEx(Executable methodOrConstructor) { -int parameterCount = methodOrConstructor.getParameterCount(); -List parameterNames = new ArrayList<>(parameterCount); - -for (int i = 0; i < parameterCount; i++) { - parameterNames.add(ParamUtils.getParameterName(methodOrConstructor, i)); +Parameter[] parameters = methodOrConstructor.getParameters(); +List parameterNames = new ArrayList<>(parameters.length); +for (int idx = 0; idx < parameters.length; idx++) { + Parameter parameter = parameters[idx]; + String parameterName = parameter.isNamePresent() ? parameter.getName() : "arg" + idx; + parameterNames.add(parameterName); } return Collections.unmodifiableList(parameterNames); }
[servicecomb-java-chassis] branch weak-contract-type updated (d7c08e5 -> 42c59e4)
This is an automated email from the ASF dual-hosted git repository. liubao pushed a change to branch weak-contract-type in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git. from d7c08e5 [SCB-1346][WIP][WEAK] only special type need convert logic new e1d1c7d [SCB-1212[WIP][WEAK] response mapper not depend on swagger class generation new 396eed0 [SCB-1212[WIP][WEAK] add ScbResponse mapper new 6c108b3 [SCB-1212[WIP][WEAK] consumer response mapper switch to new mechanism new f944fbf [SCB-1212[WIP][WEAK] producer response mapper switch to new mechanism new e0e8bd7 [SCB-1212[WIP][WEAK] SwaggerEnvironment switch to new mechanism new 9473d94 [SCB-1212[WIP][WEAK] jaxrs response mapper switch to new mechanism new 42c59e4 [SCB-1212[WIP][WEAK] springMVC response mapper switch to new mechanism The 7 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: .../swagger/engine/SwaggerEnvironment.java | 22 ++-- .../swagger/engine/SwaggerProducer.java| 22 .../generator/ScbResponseProcessor.java} | 19 ++-- .../invocation/response/ResponseMapperFactory.java | 10 +- .../response/ResponseMapperFactorys.java | 19 +--- .../swagger/invocation/response/ResponseMeta.java | 63 .../invocation/response/ResponseMetaMapper.java| 4 +- .../swagger/invocation/response/ResponsesMeta.java | 96 +++--- ...letableFutureConsumerResponseMapperFactory.java | 6 +- .../CseResponseConsumerResponseMapperFactory.java | 4 +- .../consumer/DefaultConsumerResponseMapper.java| 9 +- .../DefaultConsumerResponseMapperFactory.java | 16 +-- .../OptionalConsumerResponseMapperFactory.java | 6 +- ...letableFutureProducerResponseMapperFactory.java | 6 +- .../CseResponseProducerResponseMapperFactory.java | 4 +- .../producer/DefaultProducerResponseMapper.java| 10 +- .../DefaultProducerResponseMapperFactory.java | 16 +-- .../OptionalProducerResponseMapperFactory.java | 6 +- ...icecomb.swagger.generator.ResponseTypeProcessor | 2 +- .../swagger/engine/TestSwaggerEnvironment.java | 62 ++-- .../response/TestResponseMapperFactorys.java | 89 - .../invocation/response/TestResponsesMeta.java | 37 +++ ...letableFutureConsumerResponseMapperFactory.java | 76 -- .../TestConsumerResponseMapperFactorys.java| 96 ++ ...stCseResponseConsumerResponseMapperFactory.java | 43 .../TestDefaultConsumerResponseMapper.java | 37 --- .../TestDefaultConsumerResponseMapperFactory.java | 51 -- ...letableFutureProducerResponseMapperFactory.java | 76 -- ...stCseResponseProducerResponseMapperFactory.java | 45 - .../TestDefaultProducerResponseMapper.java | 40 .../TestDefaultProducerResponseMapperFactory.java | 55 -- .../TestProducerResponseMapperFactorys.java| 111 + .../swagger-invocation/invocation-jaxrs/pom.xml| 12 ++- .../response/JaxrsConsumerResponseMapper.java | 16 ++- .../JaxrsConsumerResponseMapperFactory.java| 4 +- .../JaxrsProducerResponseMapperFactory.java| 4 +- .../response/TestJaxrsConsumerResponseMapper.java | 100 +++ .../TestJaxrsConsumerResponseMapperFactory.java| 43 .../TestJaxrsProducerResponseMapperFactory.java| 6 +- .../response/SpringmvcConsumerResponseMapper.java | 18 +++- .../SpringmvcConsumerResponseMapperFactory.java| 6 +- .../SpringmvcProducerResponseMapperFactory.java| 6 +- .../TestSpringmvcConsumerResponseMapper.java | 79 +++ ...TestSpringmvcConsumerResponseMapperFactory.java | 101 --- ...TestSpringmvcProducerResponseMapperFactory.java | 20 ++-- 45 files changed, 516 insertions(+), 1057 deletions(-) copy swagger/{swagger-generator/generator-jaxrs/src/main/java/org/apache/servicecomb/swagger/generator/jaxrs/processor/annotation/PathMethodAnnotationProcessor.java => swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/generator/ScbResponseProcessor.java} (65%) delete mode 100644 swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/ResponseMeta.java copy common/common-rest/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.filter.HttpServerFilter => swagger/swagger-invocation/invocation-core/src/main/resources/META-INF/services/org.apache.servicecomb.swagger.generator.ResponseTypeProcessor (91%) delete mode 100644
[servicecomb-java-chassis] 04/07: [SCB-1212[WIP][WEAK] producer response mapper switch to new mechanism
This is an automated email from the ASF dual-hosted git repository. liubao pushed a commit to branch weak-contract-type in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git commit f944fbf53d39f5e285bfa8760b12d4cda6cfeff6 Author: wujimin AuthorDate: Wed Jul 3 21:53:07 2019 +0800 [SCB-1212[WIP][WEAK] producer response mapper switch to new mechanism --- ...letableFutureProducerResponseMapperFactory.java | 6 +- .../CseResponseProducerResponseMapperFactory.java | 4 +- .../producer/DefaultProducerResponseMapper.java| 10 +- .../DefaultProducerResponseMapperFactory.java | 16 +-- .../OptionalProducerResponseMapperFactory.java | 6 +- ...letableFutureProducerResponseMapperFactory.java | 76 -- ...stCseResponseProducerResponseMapperFactory.java | 45 - .../TestDefaultProducerResponseMapper.java | 40 .../TestDefaultProducerResponseMapperFactory.java | 55 -- .../TestProducerResponseMapperFactorys.java| 111 + 10 files changed, 123 insertions(+), 246 deletions(-) diff --git a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/producer/CompletableFutureProducerResponseMapperFactory.java b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/producer/CompletableFutureProducerResponseMapperFactory.java index 2191608..5476719 100644 --- a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/producer/CompletableFutureProducerResponseMapperFactory.java +++ b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/producer/CompletableFutureProducerResponseMapperFactory.java @@ -24,7 +24,7 @@ import org.apache.servicecomb.swagger.invocation.response.ResponseMapperFactorys public class CompletableFutureProducerResponseMapperFactory implements ProducerResponseMapperFactory { @Override - public boolean isMatch(Type swaggerType, Type producerType) { + public boolean isMatch(Type producerType) { if (!ParameterizedType.class.isAssignableFrom(producerType.getClass())) { return false; } @@ -34,8 +34,8 @@ public class CompletableFutureProducerResponseMapperFactory implements ProducerR @Override public ProducerResponseMapper createResponseMapper(ResponseMapperFactorys factorys, - Type swaggerType, Type producerType) { + Type producerType) { Type realProducerType = ((ParameterizedType) producerType).getActualTypeArguments()[0]; -return factorys.createResponseMapper(swaggerType, realProducerType); +return factorys.createResponseMapper(realProducerType); } } diff --git a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/producer/CseResponseProducerResponseMapperFactory.java b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/producer/CseResponseProducerResponseMapperFactory.java index b736522..4434872 100644 --- a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/producer/CseResponseProducerResponseMapperFactory.java +++ b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/producer/CseResponseProducerResponseMapperFactory.java @@ -25,13 +25,13 @@ public class CseResponseProducerResponseMapperFactory implements ProducerRespons private static final ProducerResponseMapper SAME = (status, response) -> (Response) response; @Override - public boolean isMatch(Type swaggerType, Type producerType) { + public boolean isMatch(Type producerType) { return producerType.equals(Response.class); } @Override public ProducerResponseMapper createResponseMapper(ResponseMapperFactorys factorys, - Type swaggerType, Type producerType) { + Type producerType) { return SAME; } } diff --git a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/producer/DefaultProducerResponseMapper.java b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/producer/DefaultProducerResponseMapper.java index 2d35e7c..aa4f2ce 100644 --- a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/producer/DefaultProducerResponseMapper.java +++ b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/producer/DefaultProducerResponseMapper.java @@ -19,18 +19,10 @@ package org.apache.servicecomb.swagger.invocation.response.producer; import javax.ws.rs.core.Response.StatusType; import org.apache.servicecomb.swagger.invocation.Response; -import
[servicecomb-java-chassis] 03/07: [SCB-1212[WIP][WEAK] consumer response mapper switch to new mechanism
This is an automated email from the ASF dual-hosted git repository. liubao pushed a commit to branch weak-contract-type in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git commit 6c108b3e68ffed0ca1801db9056c97b424149257 Author: wujimin AuthorDate: Wed Jul 3 21:51:13 2019 +0800 [SCB-1212[WIP][WEAK] consumer response mapper switch to new mechanism --- ...letableFutureConsumerResponseMapperFactory.java | 6 +- .../CseResponseConsumerResponseMapperFactory.java | 4 +- .../consumer/DefaultConsumerResponseMapper.java| 9 +- .../DefaultConsumerResponseMapperFactory.java | 16 +--- .../OptionalConsumerResponseMapperFactory.java | 6 +- ...letableFutureConsumerResponseMapperFactory.java | 76 - .../TestConsumerResponseMapperFactorys.java| 96 ++ ...stCseResponseConsumerResponseMapperFactory.java | 43 -- .../TestDefaultConsumerResponseMapper.java | 37 - .../TestDefaultConsumerResponseMapperFactory.java | 51 10 files changed, 108 insertions(+), 236 deletions(-) diff --git a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/consumer/CompletableFutureConsumerResponseMapperFactory.java b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/consumer/CompletableFutureConsumerResponseMapperFactory.java index 742958d..eabe5fd 100644 --- a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/consumer/CompletableFutureConsumerResponseMapperFactory.java +++ b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/consumer/CompletableFutureConsumerResponseMapperFactory.java @@ -24,7 +24,7 @@ import org.apache.servicecomb.swagger.invocation.response.ResponseMapperFactorys public class CompletableFutureConsumerResponseMapperFactory implements ConsumerResponseMapperFactory { @Override - public boolean isMatch(Type swaggerType, Type consumerType) { + public boolean isMatch(Type consumerType) { if (!ParameterizedType.class.isAssignableFrom(consumerType.getClass())) { return false; } @@ -34,8 +34,8 @@ public class CompletableFutureConsumerResponseMapperFactory implements ConsumerR @Override public ConsumerResponseMapper createResponseMapper(ResponseMapperFactorys factorys, - Type swaggerType, Type consumerType) { + Type consumerType) { Type realConsumerType = ((ParameterizedType) consumerType).getActualTypeArguments()[0]; -return factorys.createResponseMapper(swaggerType, realConsumerType); +return factorys.createResponseMapper(realConsumerType); } } diff --git a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/consumer/CseResponseConsumerResponseMapperFactory.java b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/consumer/CseResponseConsumerResponseMapperFactory.java index 86c294b..34fcafd 100644 --- a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/consumer/CseResponseConsumerResponseMapperFactory.java +++ b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/consumer/CseResponseConsumerResponseMapperFactory.java @@ -25,13 +25,13 @@ public class CseResponseConsumerResponseMapperFactory implements ConsumerRespons private static final ConsumerResponseMapper SAME = response -> response; @Override - public boolean isMatch(Type swaggerType, Type consumerType) { + public boolean isMatch(Type consumerType) { return Response.class.equals(consumerType); } @Override public ConsumerResponseMapper createResponseMapper(ResponseMapperFactorys factorys, - Type swaggerType, Type consumerType) { + Type consumerType) { return SAME; } } diff --git a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/consumer/DefaultConsumerResponseMapper.java b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/consumer/DefaultConsumerResponseMapper.java index e43e37e..d430050 100644 --- a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/consumer/DefaultConsumerResponseMapper.java +++ b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/consumer/DefaultConsumerResponseMapper.java @@ -17,17 +17,10 @@ package org.apache.servicecomb.swagger.invocation.response.consumer; import org.apache.servicecomb.swagger.invocation.Response; -import org.apache.servicecomb.swagger.invocation.converter.Converter; public class
[servicecomb-java-chassis] 01/07: [SCB-1212[WIP][WEAK] response mapper not depend on swagger class generation
This is an automated email from the ASF dual-hosted git repository. liubao pushed a commit to branch weak-contract-type in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git commit e1d1c7db7b3f684a4c783d743da0c28a6871a9b1 Author: wujimin AuthorDate: Wed Jul 3 21:37:57 2019 +0800 [SCB-1212[WIP][WEAK] response mapper not depend on swagger class generation --- .../invocation/response/ResponseMapperFactory.java | 10 +-- .../response/ResponseMapperFactorys.java | 19 + .../swagger/invocation/response/ResponseMeta.java | 63 -- .../invocation/response/ResponseMetaMapper.java| 4 +- .../swagger/invocation/response/ResponsesMeta.java | 96 +- .../response/TestResponseMapperFactorys.java | 89 .../invocation/response/TestResponsesMeta.java | 37 - 7 files changed, 83 insertions(+), 235 deletions(-) diff --git a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/ResponseMapperFactory.java b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/ResponseMapperFactory.java index 70d8871..73a2f1a 100644 --- a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/ResponseMapperFactory.java +++ b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/ResponseMapperFactory.java @@ -18,18 +18,12 @@ package org.apache.servicecomb.swagger.invocation.response; import java.lang.reflect.Type; -import org.apache.servicecomb.swagger.invocation.converter.ConverterMgr; - public interface ResponseMapperFactory { default int getOrder() { return 0; } - default void setConverterMgr(ConverterMgr converterMgr) { - } - - boolean isMatch(Type swaggerType, Type providerType); + boolean isMatch(Type providerType); - MAPPER createResponseMapper(ResponseMapperFactorys factorys, Type swaggerType, - Type providerType); + MAPPER createResponseMapper(ResponseMapperFactorys factorys, Type providerType); } diff --git a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/ResponseMapperFactorys.java b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/ResponseMapperFactorys.java index 92e95c6..9a37037 100644 --- a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/ResponseMapperFactorys.java +++ b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/ResponseMapperFactorys.java @@ -20,37 +20,26 @@ import java.lang.reflect.Type; import java.util.List; import org.apache.servicecomb.foundation.common.utils.SPIServiceUtils; -import org.apache.servicecomb.swagger.invocation.converter.ConverterMgr; public class ResponseMapperFactorys { private List> factorys; - public ResponseMapperFactorys(Class> factoryCls, ConverterMgr converterMgr) { -this(factoryCls); -this.setConverterMgr(converterMgr); - } - @SuppressWarnings("unchecked") public ResponseMapperFactorys(Class> factoryCls) { factorys = (List>) SPIServiceUtils.getSortedService(factoryCls); } - public void setConverterMgr(ConverterMgr converterMgr) { -factorys.forEach(factory -> factory.setConverterMgr(converterMgr)); - } - - public MAPPER createResponseMapper(Type swaggerType, Type providerType) { + public MAPPER createResponseMapper(Type providerType) { for (ResponseMapperFactory factory : factorys) { - if (!factory.isMatch(swaggerType, providerType)) { + if (!factory.isMatch(providerType)) { continue; } - return factory.createResponseMapper(this, swaggerType, providerType); + return factory.createResponseMapper(this, providerType); } throw new IllegalStateException( -String.format("can not find response mapper for %s and %s, this should never happened.", -swaggerType.getTypeName(), +String.format("can not find response mapper for %s, this should never happened.", providerType.getTypeName())); } } diff --git a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/ResponseMeta.java b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/ResponseMeta.java deleted file mode 100644 index 3aade01..000 --- a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/response/ResponseMeta.java +++ /dev/null @@ -1,63 +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
[servicecomb-java-chassis] 02/07: [SCB-1212[WIP][WEAK] add ScbResponse mapper
This is an automated email from the ASF dual-hosted git repository. liubao pushed a commit to branch weak-contract-type in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git commit 396eed071209a2e30e3ab60bb1d10e0d39b1cff9 Author: wujimin AuthorDate: Wed Jul 3 21:40:15 2019 +0800 [SCB-1212[WIP][WEAK] add ScbResponse mapper --- .../invocation/generator/ScbResponseProcessor.java | 37 ++ ...icecomb.swagger.generator.ResponseTypeProcessor | 18 +++ 2 files changed, 55 insertions(+) diff --git a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/generator/ScbResponseProcessor.java b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/generator/ScbResponseProcessor.java new file mode 100644 index 000..f77062d --- /dev/null +++ b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/generator/ScbResponseProcessor.java @@ -0,0 +1,37 @@ +/* + * 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.swagger.invocation.generator; + +import java.lang.reflect.Type; + +import org.apache.servicecomb.swagger.generator.OperationGenerator; +import org.apache.servicecomb.swagger.generator.SwaggerGenerator; +import org.apache.servicecomb.swagger.generator.core.processor.response.DefaultResponseTypeProcessor; +import org.apache.servicecomb.swagger.invocation.Response; + +public class ScbResponseProcessor extends DefaultResponseTypeProcessor { + @Override + public Class getProcessType() { +return Response.class; + } + + @Override + public Type extractResponseType(SwaggerGenerator swaggerGenerator, OperationGenerator operationGenerator, + Type genericResponseType) { +return null; + } +} diff --git a/swagger/swagger-invocation/invocation-core/src/main/resources/META-INF/services/org.apache.servicecomb.swagger.generator.ResponseTypeProcessor b/swagger/swagger-invocation/invocation-core/src/main/resources/META-INF/services/org.apache.servicecomb.swagger.generator.ResponseTypeProcessor new file mode 100644 index 000..1a722b7 --- /dev/null +++ b/swagger/swagger-invocation/invocation-core/src/main/resources/META-INF/services/org.apache.servicecomb.swagger.generator.ResponseTypeProcessor @@ -0,0 +1,18 @@ +# +# 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. +# + +org.apache.servicecomb.swagger.invocation.generator.ScbResponseProcessor \ No newline at end of file
[servicecomb-java-chassis] 07/07: [SCB-1212[WIP][WEAK] springMVC response mapper switch to new mechanism
This is an automated email from the ASF dual-hosted git repository. liubao pushed a commit to branch weak-contract-type in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git commit 42c59e4a9f8696f63a8b8744175f67a6cf93d45d Author: wujimin AuthorDate: Wed Jul 3 23:15:24 2019 +0800 [SCB-1212[WIP][WEAK] springMVC response mapper switch to new mechanism --- .../response/SpringmvcConsumerResponseMapper.java | 18 +++- .../SpringmvcConsumerResponseMapperFactory.java| 6 +- .../SpringmvcProducerResponseMapperFactory.java| 6 +- .../TestSpringmvcConsumerResponseMapper.java | 79 +++- ...TestSpringmvcConsumerResponseMapperFactory.java | 101 - ...TestSpringmvcProducerResponseMapperFactory.java | 20 ++-- 6 files changed, 84 insertions(+), 146 deletions(-) diff --git a/swagger/swagger-invocation/invocation-springmvc/src/main/java/org/apache/servicecomb/swagger/invocation/springmvc/response/SpringmvcConsumerResponseMapper.java b/swagger/swagger-invocation/invocation-springmvc/src/main/java/org/apache/servicecomb/swagger/invocation/springmvc/response/SpringmvcConsumerResponseMapper.java index 92e439b..b50ac32 100644 --- a/swagger/swagger-invocation/invocation-springmvc/src/main/java/org/apache/servicecomb/swagger/invocation/springmvc/response/SpringmvcConsumerResponseMapper.java +++ b/swagger/swagger-invocation/invocation-springmvc/src/main/java/org/apache/servicecomb/swagger/invocation/springmvc/response/SpringmvcConsumerResponseMapper.java @@ -37,12 +37,20 @@ public class SpringmvcConsumerResponseMapper implements ConsumerResponseMapper { public Object mapResponse(Response response) { HttpStatus status = HttpStatus.valueOf(response.getStatusCode()); -HttpHeaders httpHeaders = null; Map> headers = response.getHeaders().getHeaderMap(); -if (headers != null) { - httpHeaders = new HttpHeaders(); - for (Entry> entry : headers.entrySet()) { -for (Object value : entry.getValue()) { +if (headers == null) { + Object realResult = realMapper.mapResponse(response); + return new ResponseEntity<>(realResult, null, status); +} + +HttpHeaders httpHeaders = new HttpHeaders(); +for (Entry> entry : headers.entrySet()) { + if (entry.getValue() == null) { +continue; + } + + for (Object value : entry.getValue()) { +if (value != null) { httpHeaders.add(entry.getKey(), String.valueOf(value)); } } diff --git a/swagger/swagger-invocation/invocation-springmvc/src/main/java/org/apache/servicecomb/swagger/invocation/springmvc/response/SpringmvcConsumerResponseMapperFactory.java b/swagger/swagger-invocation/invocation-springmvc/src/main/java/org/apache/servicecomb/swagger/invocation/springmvc/response/SpringmvcConsumerResponseMapperFactory.java index 3887e4a..9fa48f7 100644 --- a/swagger/swagger-invocation/invocation-springmvc/src/main/java/org/apache/servicecomb/swagger/invocation/springmvc/response/SpringmvcConsumerResponseMapperFactory.java +++ b/swagger/swagger-invocation/invocation-springmvc/src/main/java/org/apache/servicecomb/swagger/invocation/springmvc/response/SpringmvcConsumerResponseMapperFactory.java @@ -26,7 +26,7 @@ import org.springframework.http.ResponseEntity; public class SpringmvcConsumerResponseMapperFactory implements ConsumerResponseMapperFactory { @Override - public boolean isMatch(Type swaggerType, Type consumerType) { + public boolean isMatch(Type consumerType) { if (!ParameterizedType.class.isAssignableFrom(consumerType.getClass())) { return false; } @@ -36,9 +36,9 @@ public class SpringmvcConsumerResponseMapperFactory implements ConsumerResponseM @Override public ConsumerResponseMapper createResponseMapper(ResponseMapperFactorys factorys, - Type swaggerType, Type consumerType) { + Type consumerType) { Type realConsumerType = ((ParameterizedType) consumerType).getActualTypeArguments()[0]; -ConsumerResponseMapper realMapper = factorys.createResponseMapper(swaggerType, realConsumerType); +ConsumerResponseMapper realMapper = factorys.createResponseMapper(realConsumerType); return new SpringmvcConsumerResponseMapper(realMapper); } } diff --git a/swagger/swagger-invocation/invocation-springmvc/src/main/java/org/apache/servicecomb/swagger/invocation/springmvc/response/SpringmvcProducerResponseMapperFactory.java b/swagger/swagger-invocation/invocation-springmvc/src/main/java/org/apache/servicecomb/swagger/invocation/springmvc/response/SpringmvcProducerResponseMapperFactory.java index d01a93d..c3bee1c 100644 --- a/swagger/swagger-invocation/invocation-springmvc/src/main/java/org/apache/servicecomb/swagger/invocation/springmvc/response/SpringmvcProducerResponseMapperFactory.java +++
[servicecomb-java-chassis] 06/07: [SCB-1212[WIP][WEAK] jaxrs response mapper switch to new mechanism
This is an automated email from the ASF dual-hosted git repository. liubao pushed a commit to branch weak-contract-type in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git commit 9473d949839019ea2d89e500dddf186d08189da9 Author: wujimin AuthorDate: Wed Jul 3 23:11:59 2019 +0800 [SCB-1212[WIP][WEAK] jaxrs response mapper switch to new mechanism --- .../swagger-invocation/invocation-jaxrs/pom.xml| 12 ++- .../response/JaxrsConsumerResponseMapper.java | 16 +++- .../JaxrsConsumerResponseMapperFactory.java| 4 +- .../JaxrsProducerResponseMapperFactory.java| 4 +- .../response/TestJaxrsConsumerResponseMapper.java | 100 - .../TestJaxrsConsumerResponseMapperFactory.java| 43 - .../TestJaxrsProducerResponseMapperFactory.java| 6 +- 7 files changed, 69 insertions(+), 116 deletions(-) diff --git a/swagger/swagger-invocation/invocation-jaxrs/pom.xml b/swagger/swagger-invocation/invocation-jaxrs/pom.xml index 37c017d..df3a21a 100644 --- a/swagger/swagger-invocation/invocation-jaxrs/pom.xml +++ b/swagger/swagger-invocation/invocation-jaxrs/pom.xml @@ -26,11 +26,21 @@ swagger-invocation-jaxrs Java Chassis::Swagger::Invocation::JAXRS - org.apache.servicecomb swagger-invocation-core + + org.apache.servicecomb + swagger-generator-jaxrs + + + + org.glassfish.jersey.core + jersey-client + 2.28 + test + diff --git a/swagger/swagger-invocation/invocation-jaxrs/src/main/java/org/apache/servicecomb/swagger/invocation/jaxrs/response/JaxrsConsumerResponseMapper.java b/swagger/swagger-invocation/invocation-jaxrs/src/main/java/org/apache/servicecomb/swagger/invocation/jaxrs/response/JaxrsConsumerResponseMapper.java index f499b7b..f8b5373 100644 --- a/swagger/swagger-invocation/invocation-jaxrs/src/main/java/org/apache/servicecomb/swagger/invocation/jaxrs/response/JaxrsConsumerResponseMapper.java +++ b/swagger/swagger-invocation/invocation-jaxrs/src/main/java/org/apache/servicecomb/swagger/invocation/jaxrs/response/JaxrsConsumerResponseMapper.java @@ -32,9 +32,19 @@ public class JaxrsConsumerResponseMapper implements ConsumerResponseMapper { javax.ws.rs.core.Response.status(response.getStatus()).entity(response.getResult()); Map> headers = response.getHeaders().getHeaderMap(); -if (headers != null) { - for (Entry> entry : headers.entrySet()) { -responseBuilder.header(entry.getKey(), entry.getValue()); +if (headers == null) { + return responseBuilder.build(); +} + +for (Entry> entry : headers.entrySet()) { + if (entry.getValue() == null) { +continue; + } + + for (Object value : entry.getValue()) { +if (value != null) { + responseBuilder.header(entry.getKey(), value); +} } } diff --git a/swagger/swagger-invocation/invocation-jaxrs/src/main/java/org/apache/servicecomb/swagger/invocation/jaxrs/response/JaxrsConsumerResponseMapperFactory.java b/swagger/swagger-invocation/invocation-jaxrs/src/main/java/org/apache/servicecomb/swagger/invocation/jaxrs/response/JaxrsConsumerResponseMapperFactory.java index abf491e..c0b0b6b 100644 --- a/swagger/swagger-invocation/invocation-jaxrs/src/main/java/org/apache/servicecomb/swagger/invocation/jaxrs/response/JaxrsConsumerResponseMapperFactory.java +++ b/swagger/swagger-invocation/invocation-jaxrs/src/main/java/org/apache/servicecomb/swagger/invocation/jaxrs/response/JaxrsConsumerResponseMapperFactory.java @@ -26,13 +26,13 @@ import org.apache.servicecomb.swagger.invocation.response.consumer.ConsumerRespo public class JaxrsConsumerResponseMapperFactory implements ConsumerResponseMapperFactory { @Override - public boolean isMatch(Type swaggerType, Type consumerType) { + public boolean isMatch(Type consumerType) { return Response.class.equals(consumerType); } @Override public ConsumerResponseMapper createResponseMapper(ResponseMapperFactorys factorys, - Type swaggerType, Type consumerType) { + Type consumerType) { return new JaxrsConsumerResponseMapper(); } } diff --git a/swagger/swagger-invocation/invocation-jaxrs/src/main/java/org/apache/servicecomb/swagger/invocation/jaxrs/response/JaxrsProducerResponseMapperFactory.java b/swagger/swagger-invocation/invocation-jaxrs/src/main/java/org/apache/servicecomb/swagger/invocation/jaxrs/response/JaxrsProducerResponseMapperFactory.java index 14a0ff6..7afbdcd 100644 --- a/swagger/swagger-invocation/invocation-jaxrs/src/main/java/org/apache/servicecomb/swagger/invocation/jaxrs/response/JaxrsProducerResponseMapperFactory.java +++ b/swagger/swagger-invocation/invocation-jaxrs/src/main/java/org/apache/servicecomb/swagger/invocation/jaxrs/response/JaxrsProducerResponseMapperFactory.java @@ -26,13 +26,13 @@ import org.apache.servicecomb.swagger.invocation.response.producer.ProducerRespo public
[GitHub] [servicecomb-java-chassis] liubao68 merged pull request #1259: [SCB-1212[WIP][WEAK] Weak response mapper
liubao68 merged pull request #1259: [SCB-1212[WIP][WEAK] Weak response mapper URL: https://github.com/apache/servicecomb-java-chassis/pull/1259 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[servicecomb-java-chassis] 05/07: [SCB-1212[WIP][WEAK] SwaggerEnvironment switch to new mechanism
This is an automated email from the ASF dual-hosted git repository. liubao pushed a commit to branch weak-contract-type in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git commit e0e8bd7ac91e61172be423022685d96c5fadc97d Author: wujimin AuthorDate: Wed Jul 3 22:46:11 2019 +0800 [SCB-1212[WIP][WEAK] SwaggerEnvironment switch to new mechanism --- .../swagger/engine/SwaggerEnvironment.java | 22 .../swagger/engine/SwaggerProducer.java| 22 .../swagger/engine/TestSwaggerEnvironment.java | 62 +++--- 3 files changed, 39 insertions(+), 67 deletions(-) diff --git a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/engine/SwaggerEnvironment.java b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/engine/SwaggerEnvironment.java index 03cf6da..b3f787d 100644 --- a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/engine/SwaggerEnvironment.java +++ b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/engine/SwaggerEnvironment.java @@ -50,17 +50,14 @@ import io.swagger.util.Json; public class SwaggerEnvironment { private static final Logger LOGGER = LoggerFactory.getLogger(SwaggerEnvironment.class); - private ResponseMapperFactorys producerResponseMapperFactorys = - new ResponseMapperFactorys<>(ProducerResponseMapperFactory.class); - - private ResponseMapperFactorys consumerResponseMapperFactorys = - new ResponseMapperFactorys<>(ConsumerResponseMapperFactory.class); - public SwaggerConsumer createConsumer(Class consumerIntf, Swagger swagger) { Map, ContextArgumentMapperFactory> contextFactorys = SPIServiceUtils .getOrLoadSortedService(ConsumerContextArgumentMapperFactory.class) .stream() .collect(Collectors.toMap(ConsumerContextArgumentMapperFactory::getContextClass, Function.identity())); +ResponseMapperFactorys consumerResponseMapperFactorys = +new ResponseMapperFactorys<>(ConsumerResponseMapperFactory.class); + SwaggerOperations swaggerOperations = new SwaggerOperations(swagger); SwaggerConsumer consumer = new SwaggerConsumer(); @@ -83,10 +80,8 @@ public class SwaggerEnvironment { consumerMethod, swaggerOperation); ConsumerArgumentsMapper argsMapper = creator.createArgumentsMapper(); - ConsumerResponseMapper responseMapper = null; -// consumerResponseMapperFactorys.createResponseMapper( -// swaggerOperation.getGenericReturnType(), -// consumerMethod.getGenericReturnType()); + ConsumerResponseMapper responseMapper = consumerResponseMapperFactorys + .createResponseMapper(consumerMethod.getGenericReturnType()); SwaggerConsumerOperation op = new SwaggerConsumerOperation(); op.setConsumerMethod(consumerMethod); @@ -119,13 +114,18 @@ public class SwaggerEnvironment { .getOrLoadSortedService(ProducerContextArgumentMapperFactory.class) .stream() .collect(Collectors.toMap(ProducerContextArgumentMapperFactory::getContextClass, Function.identity())); +ResponseMapperFactorys producerResponseMapperFactorys = +new ResponseMapperFactorys<>(ProducerResponseMapperFactory.class); + SwaggerOperations swaggerOperations = new SwaggerOperations(swagger); Class producerCls = BeanUtils.getImplClassFromBean(producerInstance); Map visibleProducerMethods = retrieveVisibleMethods(producerCls); SwaggerProducer producer = new SwaggerProducer(); +producer.setSwagger(swagger); producer.setProducerCls(producerCls); +producer.setProducerInstance(producerInstance); for (SwaggerOperation swaggerOperation : swaggerOperations.getOperations().values()) { String operationId = swaggerOperation.getOperationId(); // producer参数不一定等于swagger参数 @@ -145,7 +145,6 @@ public class SwaggerEnvironment { swaggerOperation); ProducerArgumentsMapper argsMapper = creator.createArgumentsMapper(); ProducerResponseMapper responseMapper = producerResponseMapperFactorys.createResponseMapper( - swaggerMethod.getGenericReturnType(), producerMethod.getGenericReturnType()); SwaggerProducerOperation op = new SwaggerProducerOperation(); @@ -153,6 +152,7 @@ public class SwaggerEnvironment { op.setProducerInstance(producerInstance); op.setProducerMethod(producerMethod); op.setSwaggerOperation(swaggerOperation); + op.setSwaggerParameterTypes(creator.getSwaggerParameterTypes()); op.setArgumentsMapper(argsMapper); op.setResponseMapper(responseMapper); diff --git a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/engine/SwaggerProducer.java
[GitHub] [servicecomb-pack] chanjarster opened a new pull request #489: Fix typo on ParametersContext class
chanjarster opened a new pull request #489: Fix typo on ParametersContext class URL: https://github.com/apache/servicecomb-pack/pull/489 Follow this checklist to help us incorporate your contribution quickly and easily: - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes. - [x] Each commit in the pull request should have a meaningful subject line and body. - [ ] Format the pull request title like `[SCB-XXX] Fixes bug in ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA issue. - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [ ] Run `mvn clean install` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically. - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). --- Change `ParametersContext.putParamters` to `putParameters` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[servicecomb-java-chassis] branch weak-contract-type updated: [SCB-1346][WIP][WEAK] only special type need convert logic
This is an automated email from the ASF dual-hosted git repository. liubao pushed a commit to branch weak-contract-type in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git The following commit(s) were added to refs/heads/weak-contract-type by this push: new d7c08e5 [SCB-1346][WIP][WEAK] only special type need convert logic d7c08e5 is described below commit d7c08e59e1a36568dace02239427d992e80e2828 Author: wujimin AuthorDate: Wed Jul 3 01:23:08 2019 +0800 [SCB-1346][WIP][WEAK] only special type need convert logic --- .../swagger/invocation/converter/Converter.java| 6 + .../swagger/invocation/converter/ConverterMgr.java | 197 - .../invocation/converter/CustomizedConverter.java | 25 --- .../invocation/converter/impl/ConverterCommon.java | 38 .../converter/impl/part/BytesToPartConverter.java | 6 +- .../converter/impl/part/FileToPartConverter.java | 6 +- .../impl/part/InputStreamToPartConverter.java | 6 +- .../PartListToPartArrayConverter.java} | 27 +-- .../PartListToPartListConverter.java} | 27 +-- .../PartToPartConverter.java} | 20 ++- .../impl/part/ResourceToPartConverter.java | 6 +- ...vicecomb.swagger.invocation.converter.Converter | 23 +++ .../invocation/converter/ConverterMgrTest.java | 44 - .../part/PartListToPartArrayConverterTest.java}| 44 ++--- .../part/PartListToPartListConverterTest.java} | 37 ++-- .../impl/part/PartToPartConverterTest.java}| 39 ++-- 16 files changed, 141 insertions(+), 410 deletions(-) diff --git a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/converter/Converter.java b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/converter/Converter.java index 34cc5ab..f3b2753 100644 --- a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/converter/Converter.java +++ b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/converter/Converter.java @@ -16,6 +16,12 @@ */ package org.apache.servicecomb.swagger.invocation.converter; +import java.lang.reflect.Type; + public interface Converter { + Type getSrcType(); + + Type getTargetType(); + Object convert(Object value); } diff --git a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/converter/ConverterMgr.java b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/converter/ConverterMgr.java deleted file mode 100644 index ec0e2b6..000 --- a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/converter/ConverterMgr.java +++ /dev/null @@ -1,197 +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.swagger.invocation.converter; - -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.commons.lang3.reflect.TypeUtils; -import org.apache.servicecomb.swagger.invocation.InvocationType; -import org.apache.servicecomb.swagger.invocation.converter.impl.ConverterCommon; -import org.apache.servicecomb.swagger.invocation.converter.impl.ConverterSame; -import org.apache.servicecomb.swagger.invocation.converter.impl.SameElementArrayToList; -import org.apache.servicecomb.swagger.invocation.converter.impl.SameElementArrayToSet; -import org.apache.servicecomb.swagger.invocation.converter.impl.SameElementCollectionToArray; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.google.inject.util.Types; - -@Component -public class ConverterMgr { - private static final Logger LOGGER = LoggerFactory.getLogger(ConverterMgr.class); - - // 第一层key是src type,第二层key是target type -
[GitHub] [servicecomb-java-chassis] liubao68 merged pull request #1258: [SCB-1346][WIP][WEAK] only special type need convert logic
liubao68 merged pull request #1258: [SCB-1346][WIP][WEAK] only special type need convert logic URL: https://github.com/apache/servicecomb-java-chassis/pull/1258 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[servicecomb-java-chassis] branch weak-contract-type updated: [SCB-1344][WIP][WEAK] use producer parameter type in producer argument mapper for wrapped body
This is an automated email from the ASF dual-hosted git repository. liubao pushed a commit to branch weak-contract-type in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git The following commit(s) were added to refs/heads/weak-contract-type by this push: new dfa1624 [SCB-1344][WIP][WEAK] use producer parameter type in producer argument mapper for wrapped body dfa1624 is described below commit dfa162449eb746af0b399627d1f834b86eaa2c3d Author: wujimin AuthorDate: Wed Jul 3 00:42:06 2019 +0800 [SCB-1344][WIP][WEAK] use producer parameter type in producer argument mapper for wrapped body --- .../swagger/engine/SwaggerProducerOperation.java | 18 .../arguments/AbstractArgumentsMapperCreator.java | 15 ++- .../producer/ProducerArgumentsMapperCreator.java | 21 -- .../SwaggerBodyFieldToProducerArgument.java| 16 +++- .../arguments/producer/TestPojoOneArg.java | 48 ++ .../swagger/invocation/schemas/ConsumerOneArg.java | 28 + .../swagger/invocation/schemas/PojoOneArg.java | 34 +++ 7 files changed, 174 insertions(+), 6 deletions(-) diff --git a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/engine/SwaggerProducerOperation.java b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/engine/SwaggerProducerOperation.java index f174415..7f5b75e 100644 --- a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/engine/SwaggerProducerOperation.java +++ b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/engine/SwaggerProducerOperation.java @@ -18,6 +18,7 @@ package org.apache.servicecomb.swagger.engine; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.lang.reflect.Type; import java.util.List; import java.util.concurrent.CompletableFuture; @@ -46,6 +47,11 @@ public class SwaggerProducerOperation { private SwaggerOperation swaggerOperation; + // swagger parameter types relate to producer + // because features of @BeanParam/query wrapper/rpc mode parameter wrapper + // types is not direct equals to producerMethod parameter types + private Type[] swaggerParameterTypes; + private ProducerArgumentsMapper argumentsMapper; private ProducerResponseMapper responseMapper; @@ -81,10 +87,22 @@ public class SwaggerProducerOperation { this.producerMethod = producerMethod; } + public SwaggerOperation getSwaggerOperation() { +return swaggerOperation; + } + public void setSwaggerOperation(SwaggerOperation swaggerOperation) { this.swaggerOperation = swaggerOperation; } + public Type[] getSwaggerParameterTypes() { +return swaggerParameterTypes; + } + + public void setSwaggerParameterTypes(Type[] swaggerParameterTypes) { +this.swaggerParameterTypes = swaggerParameterTypes; + } + public ProducerArgumentsMapper getArgumentsMapper() { return argumentsMapper; } diff --git a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/arguments/AbstractArgumentsMapperCreator.java b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/arguments/AbstractArgumentsMapperCreator.java index ba5c04f..f8b24f0 100644 --- a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/arguments/AbstractArgumentsMapperCreator.java +++ b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/arguments/AbstractArgumentsMapperCreator.java @@ -106,6 +106,8 @@ public abstract class AbstractArgumentsMapperCreator { // body index in swagger parameters protected int swaggerBodyIdx; + protected BodyParameter bodyParameter; + protected Map swaggerBodyProperties; public AbstractArgumentsMapperCreator(SerializationConfig serializationConfig, @@ -118,7 +120,7 @@ public abstract class AbstractArgumentsMapperCreator { this.swaggerParameters = new ArrayList<>(this.swaggerOperation.getOperation().getParameters()); -BodyParameter bodyParameter = findSwaggerBodyParameter(); +bodyParameter = findSwaggerBodyParameter(); swaggerBodyProperties = SwaggerUtils.getBodyProperties(swaggerOperation.getSwagger(), bodyParameter); } @@ -203,6 +205,17 @@ public abstract class AbstractArgumentsMapperCreator { return false; } +// complex scenes +// swagger: int add(Body x) +// producer: int add(int x, int y) +if (bodyParameter != null && +!SwaggerUtils.isBean(providerParameter.getType()) && +swaggerIdx == swaggerBodyIdx && +SwaggerUtils.isBean(bodyParameter.getSchema())) { + swaggerParameters.set(swaggerIdx, bodyParameter); + return false; +} + ArgumentMapper mapper =
[GitHub] [servicecomb-java-chassis] liubao68 merged pull request #1256: [SCB-1344][WIP][WEAK] use producer parameter type in producer argument mapper for wrapped body
liubao68 merged pull request #1256: [SCB-1344][WIP][WEAK] use producer parameter type in producer argument mapper for wrapped body URL: https://github.com/apache/servicecomb-java-chassis/pull/1256 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[servicecomb-website] branch asf-site updated (9ae1bf2 -> 3f2b6fc)
This is an automated email from the ASF dual-hosted git repository. ningjiang pushed a change to branch asf-site in repository https://gitbox.apache.org/repos/asf/servicecomb-website.git. from 9ae1bf2 Publish the website add 6ed709a Add Apache-ServiceComb-Meetup-2019-Shanghai-KubeCon+CloudNative+OSS-Report add f35a4fa Fix typo add 6a4c526 Update ServiceComb community introduction add 3b7cbff Merge pull request #182 from MabinGo/updateIntroduction add f4e188a add article: how to do microservice accept test new 0536a76 Merge branch 'master' into asf-site new 3f2b6fc Publish the website The 2 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: _data/authors.yml |5 + ...019-07-04-how-to-do-microservice-accept-test.md | 337 ++ .../1_ApacheServiceComb_Community_Introduction.pdf | Bin 3147607 -> 2998566 bytes .../1_ApacheServiceComb_Community_Introduction.pdf | Bin 3147607 -> 2998566 bytes .../index.html | 20 +- .../index.html | 20 +- .../index.html | 21 +- .../docs/apache-servicecomb-day-slides/index.html | 20 +- .../apache-servicecomb-incubating-day/index.html | 20 +- .../index.html | 20 +- content/cn/docs/autoscale-on-company/index.html| 20 +- .../index.html | 20 +- .../index.html | 20 +- content/cn/docs/communication-btw-sc-ms/index.html | 20 +- content/cn/docs/company-on-kubernetes/index.html | 20 +- .../cn/docs/config_center_integration/index.html | 20 +- content/cn/docs/consul-servicemesh.html| 20 +- content/cn/docs/crm-part-I/index.html | 20 +- .../customized-tracing-with-servicecomb/index.html | 20 +- .../index.html | 20 +- .../index.html | 20 +- .../index.html | 20 +- content/cn/docs/distributed_saga_1/index.html | 20 +- content/cn/docs/distributed_saga_2/index.html | 20 +- content/cn/docs/distributed_saga_3/index.html | 20 +- content/cn/docs/go-to-cloud/index.html | 20 +- .../how-to-do-microservice-accept-test/index.html | 1107 .../index.html | 20 +- .../docs/how-to-reform-a-legacy-system/index.html | 20 +- content/cn/docs/jira_beginner_guide/index.html | 20 +- content/cn/docs/join_the_community/index.html | 20 +- content/cn/docs/linuxcon-workshop-demo/index.html | 20 +- content/cn/docs/loadtest-saga-with-kubernetes.html | 20 +- .../cn/docs/maven_dependency_management/index.html | 20 +- content/cn/docs/open-design/index.html | 20 +- .../index.html | 20 +- content/cn/docs/osi-microservices/index.html | 20 +- .../index.html | 20 +- content/cn/docs/release-note-1-0-0.html| 20 +- content/cn/docs/saga_pack_design/index.html| 20 +- content/cn/docs/saga_with_cucumber/index.html | 20 +- .../seckill-development-journey-part-I/index.html | 20 +- .../seckill-development-journey-part-II/index.html | 20 +- .../index.html | 20 +- .../cn/docs/servicecomb-pack-cluster/index.html| 20 +- content/cn/docs/servicecomb-pack-consul/index.html | 20 +- content/cn/docs/servicecomb-pack-eureka/index.html | 20 +- .../servicecomb-springcloud-zuul-demo/index.html | 20 +- .../index.html | 20 +- content/cn/docs/talk-to-apache-experts.html| 20 +- .../cn/docs/tracing-with-servicecomb/index.html| 20 +- content/cn/year-archive/index.html | 66 ++ .../index.html | 20 +- .../index.html | 20 +- .../index.html | 20 +- .../apache-servicecomb-incubating-day/index.html | 20 +- content/docs/autoscale-on-company/index.html | 20 +- .../index.html | 20 +- content/docs/communication-btw-sc-ms/index.html| 20 +- content/docs/company-on-kubernetes/index.html | 20 +- content/docs/distributed_saga_1/index.html | 20 +- content/docs/distributed_saga_2/index.html | 20 +- content/docs/distributed_saga_3/index.html | 20 +- content/docs/go-to-cloud/index.html| 20 +- .../docs/how-to-reform-a-legacy-system/index.html | 20 +-
[servicecomb-website] 01/02: Merge branch 'master' into asf-site
This is an automated email from the ASF dual-hosted git repository. ningjiang pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/servicecomb-website.git commit 0536a768c1ef868d98c306913b16f5e2892df642 Merge: 9ae1bf2 f4e188a Author: Willem Jiang AuthorDate: Thu Jul 4 16:02:01 2019 +0800 Merge branch 'master' into asf-site _data/authors.yml | 5 + ...019-07-04-how-to-do-microservice-accept-test.md | 337 + .../1_ApacheServiceComb_Community_Introduction.pdf | Bin 3147607 -> 2998566 bytes 3 files changed, 342 insertions(+)
[servicecomb-website] branch master updated: add article: how to do microservice accept test
This is an automated email from the ASF dual-hosted git repository. ningjiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-website.git The following commit(s) were added to refs/heads/master by this push: new f4e188a add article: how to do microservice accept test f4e188a is described below commit f4e188a0b2e3a08782d361e03c29970ce2f990db Author: Daniel Qian AuthorDate: Thu Jul 4 11:01:25 2019 +0800 add article: how to do microservice accept test --- _data/authors.yml | 5 + ...019-07-04-how-to-do-microservice-accept-test.md | 337 + 2 files changed, 342 insertions(+) diff --git a/_data/authors.yml b/_data/authors.yml index 497d042..b8787b6 100755 --- a/_data/authors.yml +++ b/_data/authors.yml @@ -64,3 +64,8 @@ Lei Zhang: uri: "http://github.com/coolbeevip; email: "coolbee...@gmail.com" bio: "Enjoy sharing, Enjoy living" +Daniel Qian: + name: "Qian Jia" + uri: "https://github.com/chanjarster; + email: "chanjars...@gmail.com" + bio: "Opensource change the world" \ No newline at end of file diff --git a/_posts/cn/2019-07-04-how-to-do-microservice-accept-test.md b/_posts/cn/2019-07-04-how-to-do-microservice-accept-test.md new file mode 100644 index 000..374be9d --- /dev/null +++ b/_posts/cn/2019-07-04-how-to-do-microservice-accept-test.md @@ -0,0 +1,337 @@ +--- +title: "如何给微服务架构的项目做验收测试?" +lang: cn +ref: how-to-do-microservice-accept-test +permalink: /cn/docs/how-to-do-microservice-accept-test/ +excerpt: "本文将介绍如何给微服务架构的项目做验收测试" +last_modified_at: 2019-07-04T10:37:43+08:00 +author: Daniel Qian +tags: [微服务] +redirect_from: + - /theme-setup/ +--- + +### 如何给微服务架构的项目做验收测试? + +基于微服务架构的应用相对于单体架构的应用而言在验收测试阶段具有以下挑战: + +1. 复数的服务增加了测试环境搭建的难度 +2. 各种异常情况的模拟变得困难,基于Mock的测试方式无法对整个调用链路作异常模拟,进而使得对整体架构的健壮性测试变得困难 +3. 基于成本和效率的原因,测试工作已经不适合通过人工完成 + +我们认为对基于微服务架构的应用的验收测试应该具有以下特征: + +1. 自动化、可重复、易于和CI工具集成 +3. 能够在测试运行时修改服务的行为 + +下面将就一个Demo来介绍如何利用 [Docker [1]](https://www.docker.com/)、[Cucumber [2]](https://cucumber.io/)、[Byteman [3]](https://byteman.jboss.org/)、[Fabric8 docker-maven-plugin [4]](https://dmp.fabric8.io/)、[Spotify dockerfile-maven-plugin [5]](https://github.com/spotify/dockerfile-maven)达成以上目标。 + +### Demo介绍 + +一共有两个服务Product Service(商品服务)和Product Price Service(商品价格服务),Product Service提供了一个查询接口用于获得商品信息及其价格信息的组合结果,这相当于跨服务的SQL JOIN。 + +下面是Product的Schema: + +```json +{ + "id": "", + "name": "", + "description": "" +} +``` + +下面是ProductPrice的Schema: + +```json +{ + "id": "", + "price": "" +} +``` + +Product Service返回的Schema则是: + +```json +{ + "products": [ +{ + "id": "", + "name": "", + "description": "", + "price": +} + ] +} +``` + +该接口的实现逻辑是: + +1. Product Service本地查询得到Product List +2. Product Service调用Product Price Service接口得到ProductPrice List +3. 拼装结果 + + +此外还有一个要求,当Product Price Service出现异常时,Product Service依然要能够返回结果,只不过`price`字段为`null`,即无论如何Product Service都要能够返回结果。 + +### 实现步骤 + + 构建Docker Image + +为了能够便利地搭建测试环境,我们需要先为Product Servcie和Product Price Service构建Docker Image。利用[Spotify dockerfile-maven-plugin [5]](https://github.com/spotify/dockerfile-maven)可以很方便地做到这一点,它没有引入额外的概念,只要你会写[Dockerfile [6]](https://docs.docker.com/engine/reference/builder/)就行。我们在Product Service和Producer Price Service的`pom.xml`中添加类似以下的配置: + +```xml + + com.spotify + dockerfile-maven-plugin + ${dockerfile-maven-plugin.version} + +msat-${project.artifactId} +${project.version} + + ${project.build.finalName}-exec.${project.packaging} + + + + + build + package + +build + + + + +``` + +并且提供了Dockerfile: + +```txt +FROM openjdk:8-jre-alpine +ARG JAR_FILE +ENV JAR_FILE=${JAR_FILE} +RUN mkdir /maven +COPY target/${JAR_FILE} /maven +COPY target/lib/byteman.jar /maven +ENTRYPOINT java $JAVA_OPTS -jar /maven/$JAR_FILE +EXPOSE 8080 +``` + +注意我们在Image中添加了byteman.jar,利用它我们可以在运行时修改程序的行为。 + + 编写验收测试脚本 + +我们新建一个验收测试的Maven项目,然后使用[Cucumber [2]](https://cucumber.io/)编写了以下两个场景的验收测试脚本: + +正常情况: + +```txt +Feature: List product information with price + + Scenario: Everything is good +Given Product Service is up and running +And Product Price Service is up and running + +When User query product list + +Then Get following products + + | id | name | description| price | + | animal-1 | dog | woof woof | 1000 | + | animal-2 | duck | quack quack| 40| + | animal-3 | fox | what does the fox say? | 5000 | +``` + +这个脚本的大致意思是在Product Service和Product Price Service都启动的情况下,当用户查询Product信息时,我们会得到上述表格中的结果。 + +Product Price Service异常情况: + +```txt +Feature: List product information with price + + Scenario: Product Price Service throws exception when being queried +Given Product Service is up and running +And Product Price Service is up and running + +Given Install the byteman script product_price_exception.btm to Product Price
[GitHub] [servicecomb-website] WillemJiang merged pull request #183: add article: how to do microservice accept test
WillemJiang merged pull request #183: add article: how to do microservice accept test URL: https://github.com/apache/servicecomb-website/pull/183 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [servicecomb-pack] cmonkey closed pull request #488: add SagaApplication.omegaCallbacks omegaCallback methods
cmonkey closed pull request #488: add SagaApplication.omegaCallbacks omegaCallback methods URL: https://github.com/apache/servicecomb-pack/pull/488 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [servicecomb-service-center] coveralls commented on issue #563: protobuf generate of syncer
coveralls commented on issue #563: protobuf generate of syncer URL: https://github.com/apache/servicecomb-service-center/pull/563#issuecomment-508373133 [![Coverage Status](https://coveralls.io/builds/24365536/badge)](https://coveralls.io/builds/24365536) Coverage decreased (-0.01%) to 60.808% when pulling **f3b24a80175b46c39c1170d68766fed0d41e7e7c on ChinX:syncer** into **5f4d89651aded55ab6f593d36afd07cff4522cc0 on apache:master**. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [servicecomb-service-center] ChinX closed pull request #563: protobuf generate of syncer
ChinX closed pull request #563: protobuf generate of syncer URL: https://github.com/apache/servicecomb-service-center/pull/563 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [servicecomb-service-center] ChinX opened a new pull request #563: protobuf generate of syncer
ChinX opened a new pull request #563: protobuf generate of syncer URL: https://github.com/apache/servicecomb-service-center/pull/563 Follow this checklist to help us incorporate your contribution quickly and easily: - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes. - [ ] Each commit in the pull request should have a meaningful subject line and body. - [ ] Format the pull request title like `[SCB-XXX] Fixes bug in ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA issue. - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [ ] Run `go build` `go test` `go fmt` `go vet` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically. - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). --- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [servicecomb-pack] cmonkey opened a new pull request #488: add SagaApplication.omegaCallbacks omegaCallback methods
cmonkey opened a new pull request #488: add SagaApplication.omegaCallbacks omegaCallback methods URL: https://github.com/apache/servicecomb-pack/pull/488 Follow this checklist to help us incorporate your contribution quickly and easily: - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes. - [ ] Each commit in the pull request should have a meaningful subject line and body. - [ ] Format the pull request title like `[SCB-XXX] Fixes bug in ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA issue. - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [ ] Run `mvn clean install` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically. - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). --- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services