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 2019/12/25 01:21:28 UTC
[servicecomb-java-chassis] branch master updated:
[SCB-1683][HIGHWAY-WEAK]using new proto API to serialize/deserialize
Requests/Responses (#1488)
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/servicecomb-java-chassis.git
The following commit(s) were added to refs/heads/master by this push:
new 27fb552 [SCB-1683][HIGHWAY-WEAK]using new proto API to serialize/deserialize Requests/Responses (#1488)
27fb552 is described below
commit 27fb552e835df2fe7dfb6759ddc9fa4f0be7fb7e
Author: bao liu <bi...@qq.com>
AuthorDate: Wed Dec 25 09:21:19 2019 +0800
[SCB-1683][HIGHWAY-WEAK]using new proto API to serialize/deserialize Requests/Responses (#1488)
---
.../protobuf/definition/OperationProtobuf.java | 55 ++++++++----
.../utils/ScopedProtobufSchemaManager.java | 14 ----
.../codec/protobuf/utils/WrapClassConfig.java | 32 -------
.../codec/protobuf/utils/WrapSchema.java | 47 -----------
.../servicecomb/codec/protobuf/utils/WrapType.java | 25 ------
.../protobuf/utils/schema/AbstractWrapSchema.java | 26 ------
.../protobuf/utils/schema/ArgsNotWrapSchema.java | 53 ------------
.../protobuf/utils/schema/ArgsWrapSchema.java | 54 ------------
.../protobuf/utils/schema/NormalWrapSchema.java | 58 -------------
.../codec/protobuf/utils/schema/NotWrapSchema.java | 52 ------------
.../protobuf/utils/schema/WrapSchemaFactory.java | 43 ----------
.../utils/schema/TestArgsNotWrapSchema.java | 95 ---------------------
.../protobuf/utils/schema/TestArgsWrapSchema.java | 97 ----------------------
.../foundation/protobuf/ProtoMapper.java | 14 ++++
.../transport/highway/HighwayCodec.java | 20 +++--
.../transport/highway/HighwayOutputStream.java | 33 +-------
.../transport/highway/HighwayServerInvoke.java | 4 +-
.../transport/highway/message/LoginRequest.java | 5 --
.../transport/highway/TestHighwayCodec.java | 23 ++---
.../highway/TestHighwayServerConnection.java | 30 -------
.../transport/highway/TestHighwayTransport.java | 10 +--
21 files changed, 81 insertions(+), 709 deletions(-)
diff --git a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/definition/OperationProtobuf.java b/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/definition/OperationProtobuf.java
index 17a0c71..d699e60 100644
--- a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/definition/OperationProtobuf.java
+++ b/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/definition/OperationProtobuf.java
@@ -17,51 +17,76 @@
package org.apache.servicecomb.codec.protobuf.definition;
+import java.util.Map;
+
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.Response.Status.Family;
import org.apache.servicecomb.codec.protobuf.utils.ScopedProtobufSchemaManager;
-import org.apache.servicecomb.codec.protobuf.utils.WrapSchema;
import org.apache.servicecomb.core.definition.OperationMeta;
+import org.apache.servicecomb.foundation.protobuf.ProtoMapper;
+import org.apache.servicecomb.foundation.protobuf.RootDeserializer;
+import org.apache.servicecomb.foundation.protobuf.RootSerializer;
+
+import io.protostuff.compiler.model.Message;
+@SuppressWarnings("rawtypes")
public class OperationProtobuf {
private ScopedProtobufSchemaManager scopedProtobufSchemaManager;
private OperationMeta operationMeta;
- private WrapSchema requestSchema;
+ private RootSerializer requestSerializer;
+
+ private RootDeserializer<Map> requestDeserializer;
+
+ private RootSerializer responseSerializer;
- private WrapSchema responseSchema;
+ private RootDeserializer<Object> responseDeserializer;
public OperationProtobuf(ScopedProtobufSchemaManager scopedProtobufSchemaManager, OperationMeta operationMeta) {
this.scopedProtobufSchemaManager = scopedProtobufSchemaManager;
this.operationMeta = operationMeta;
- requestSchema = scopedProtobufSchemaManager.getOrCreateArgsSchema(operationMeta);
+ ProtoMapper mapper = scopedProtobufSchemaManager.getOrCreateProtoMapper(operationMeta.getSchemaMeta());
+ Message requestMessage = mapper.getRequestMessage(operationMeta.getOperationId());
+ requestSerializer = mapper.createRootSerializer(requestMessage, Map.class);
+ requestDeserializer = mapper.createRootDeserializer(requestMessage, Map.class);
- responseSchema = scopedProtobufSchemaManager.getOrCreateSchema(operationMeta.getResponsesMeta().findResponseType(
- Status.OK.getStatusCode()));
+ Message responseMessage = mapper.getResponseMessage(operationMeta.getOperationId());
+ responseSerializer = mapper
+ .createRootSerializer(responseMessage,
+ operationMeta.getResponsesMeta().findResponseType(Status.OK.getStatusCode()));
+ responseDeserializer = mapper
+ .createRootDeserializer(responseMessage,
+ operationMeta.getResponsesMeta().findResponseType(Status.OK.getStatusCode()));
}
public OperationMeta getOperationMeta() {
return operationMeta;
}
- public WrapSchema getRequestSchema() {
- // TODO : work with request
- return requestSchema;
+ public RootSerializer findRequestSerializer() {
+ return requestSerializer;
}
- public WrapSchema getResponseSchema() {
- // TODO : work with response
- return responseSchema;
+ public RootDeserializer<Map> findRequestDesirializer() {
+ return requestDeserializer;
}
- public WrapSchema findResponseSchema(int statusCode) {
+ public RootSerializer findResponseSerializer(int statusCode) {
if (Family.SUCCESSFUL.equals(Family.familyOf(statusCode))) {
- return responseSchema;
+ return responseSerializer;
}
+ // TODO : handles only one response type.
+ return null;
+ }
- return scopedProtobufSchemaManager.getOrCreateSchema(operationMeta.getResponsesMeta().findResponseType(statusCode));
+ public RootDeserializer<Object> findResponseDesirialize(int statusCode) {
+ if (Family.SUCCESSFUL.equals(Family.familyOf(statusCode))) {
+ return responseDeserializer;
+ }
+ // TODO : handles only one response type.
+ return null;
}
}
diff --git a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/ScopedProtobufSchemaManager.java b/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/ScopedProtobufSchemaManager.java
index 9c157cf..51e1c0b 100644
--- a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/ScopedProtobufSchemaManager.java
+++ b/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/ScopedProtobufSchemaManager.java
@@ -17,11 +17,9 @@
package org.apache.servicecomb.codec.protobuf.utils;
-import java.lang.reflect.Type;
import java.util.Map;
import org.apache.servicecomb.codec.protobuf.internal.converter.SwaggerToProtoGenerator;
-import org.apache.servicecomb.core.definition.OperationMeta;
import org.apache.servicecomb.core.definition.SchemaMeta;
import org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx;
import org.apache.servicecomb.foundation.protobuf.ProtoMapper;
@@ -44,18 +42,6 @@ public class ScopedProtobufSchemaManager {
}
- // 适用于将单个类型包装的场景
- // 比如return
- public WrapSchema getOrCreateSchema(Type type) {
- // TODO: add implementation using new API
- return null;
- }
-
- public WrapSchema getOrCreateArgsSchema(OperationMeta operationMeta) {
- // TODO: add implementation using new API
- return null;
- }
-
/**
* get the ProtoMapper from Swagger
*/
diff --git a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/WrapClassConfig.java b/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/WrapClassConfig.java
deleted file mode 100644
index 3c1b536..0000000
--- a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/WrapClassConfig.java
+++ /dev/null
@@ -1,32 +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.codec.protobuf.utils;
-
-import org.apache.servicecomb.common.javassist.ClassConfig;
-
-public class WrapClassConfig extends ClassConfig {
- private WrapType type;
-
- public WrapType getType() {
- return type;
- }
-
- public void setType(WrapType type) {
- this.type = type;
- }
-}
diff --git a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/WrapSchema.java b/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/WrapSchema.java
deleted file mode 100644
index 6778330..0000000
--- a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/WrapSchema.java
+++ /dev/null
@@ -1,47 +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.codec.protobuf.utils;
-
-import java.nio.ByteBuffer;
-
-import io.protostuff.ByteBufferInput;
-import io.protostuff.Input;
-import io.protostuff.Output;
-import io.vertx.core.buffer.Buffer;
-
-public interface WrapSchema {
- @SuppressWarnings("unchecked")
- default <T> T readObject(Buffer buffer) throws Exception {
- if (buffer == null || buffer.length() == 0) {
- // void以及函数入参为null的场景
- // 空串时,protobuf至少为编码为1字节
- return (T) readFromEmpty();
- }
-
- ByteBuffer nioBuffer = buffer.getByteBuf().nioBuffer();
- Input input = new ByteBufferInput(nioBuffer, false);
-
- return (T) readObject(input);
- }
-
- Object readFromEmpty();
-
- Object readObject(Input input) throws Exception;
-
- void writeObject(Output output, Object value) throws Exception;
-}
diff --git a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/WrapType.java b/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/WrapType.java
deleted file mode 100644
index 7d049ed..0000000
--- a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/WrapType.java
+++ /dev/null
@@ -1,25 +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.codec.protobuf.utils;
-
-public enum WrapType {
- NOT_WRAP,
- NORMAL_WRAP,
- ARGS_NOT_WRAP,
- ARGS_WRAP
-}
diff --git a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/schema/AbstractWrapSchema.java b/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/schema/AbstractWrapSchema.java
deleted file mode 100644
index b8f5ed3..0000000
--- a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/schema/AbstractWrapSchema.java
+++ /dev/null
@@ -1,26 +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.codec.protobuf.utils.schema;
-
-import org.apache.servicecomb.codec.protobuf.utils.WrapSchema;
-
-import io.protostuff.Schema;
-
-public abstract class AbstractWrapSchema implements WrapSchema {
- protected Schema<Object> schema;
-}
diff --git a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/schema/ArgsNotWrapSchema.java b/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/schema/ArgsNotWrapSchema.java
deleted file mode 100644
index 5d76039..0000000
--- a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/schema/ArgsNotWrapSchema.java
+++ /dev/null
@@ -1,53 +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.codec.protobuf.utils.schema;
-
-import java.io.IOException;
-
-import io.protostuff.Input;
-import io.protostuff.Output;
-import io.protostuff.Schema;
-
-public class ArgsNotWrapSchema extends AbstractWrapSchema {
-
- @SuppressWarnings("unchecked")
- public ArgsNotWrapSchema(Schema<?> schema) {
- this.schema = (Schema<Object>) schema;
- }
-
- @Override
- public Object readFromEmpty() {
- return new Object[] {null};
- }
-
- public Object readObject(Input input) throws IOException {
- Object readValue = schema.newMessage();
- schema.mergeFrom(input, readValue);
-
- return new Object[] {readValue};
- }
-
- public void writeObject(Output output, Object value) throws IOException {
- Object writeValue = ((Object[]) value)[0];
- if (writeValue == null) {
- return;
- }
-
- schema.writeTo(output, writeValue);
- }
-}
diff --git a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/schema/ArgsWrapSchema.java b/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/schema/ArgsWrapSchema.java
deleted file mode 100644
index 16360a3..0000000
--- a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/schema/ArgsWrapSchema.java
+++ /dev/null
@@ -1,54 +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.codec.protobuf.utils.schema;
-
-import java.io.IOException;
-
-import org.apache.servicecomb.common.javassist.MultiWrapper;
-
-import io.protostuff.Input;
-import io.protostuff.Output;
-import io.protostuff.Schema;
-
-public class ArgsWrapSchema extends AbstractWrapSchema {
-
- @SuppressWarnings("unchecked")
- public ArgsWrapSchema(Schema<?> schema) {
- this.schema = (Schema<Object>) schema;
- }
-
- @Override
- public Object readFromEmpty() {
- MultiWrapper wrapper = (MultiWrapper) schema.newMessage();
- return wrapper.readFields();
- }
-
- public Object readObject(Input input) throws IOException {
- MultiWrapper wrapper = (MultiWrapper) schema.newMessage();
- schema.mergeFrom(input, wrapper);
-
- return wrapper.readFields();
- }
-
- public void writeObject(Output output, Object value) throws IOException {
- MultiWrapper wrapper = (MultiWrapper) schema.newMessage();
- wrapper.writeFields((Object[]) value);
-
- schema.writeTo(output, wrapper);
- }
-}
diff --git a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/schema/NormalWrapSchema.java b/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/schema/NormalWrapSchema.java
deleted file mode 100644
index f69f8e9..0000000
--- a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/schema/NormalWrapSchema.java
+++ /dev/null
@@ -1,58 +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.codec.protobuf.utils.schema;
-
-import java.io.IOException;
-
-import org.apache.servicecomb.common.javassist.SingleWrapper;
-
-import io.protostuff.Input;
-import io.protostuff.Output;
-import io.protostuff.Schema;
-
-public class NormalWrapSchema extends AbstractWrapSchema {
-
- @SuppressWarnings("unchecked")
- public NormalWrapSchema(Schema<?> schema) {
- this.schema = (Schema<Object>) schema;
- }
-
- @Override
- public Object readFromEmpty() {
- SingleWrapper wrapper = (SingleWrapper) schema.newMessage();
- return wrapper.readField();
- }
-
- public Object readObject(Input input) throws IOException {
- SingleWrapper wrapper = (SingleWrapper) schema.newMessage();
- schema.mergeFrom(input, wrapper);
-
- return wrapper.readField();
- }
-
- public void writeObject(Output output, Object value) throws IOException {
- if (value == null) {
- return;
- }
-
- SingleWrapper wrapper = (SingleWrapper) schema.newMessage();
- wrapper.writeField(value);
-
- schema.writeTo(output, wrapper);
- }
-}
diff --git a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/schema/NotWrapSchema.java b/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/schema/NotWrapSchema.java
deleted file mode 100644
index 697fe98..0000000
--- a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/schema/NotWrapSchema.java
+++ /dev/null
@@ -1,52 +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.codec.protobuf.utils.schema;
-
-import java.io.IOException;
-
-import io.protostuff.Input;
-import io.protostuff.Output;
-import io.protostuff.Schema;
-
-public class NotWrapSchema extends AbstractWrapSchema {
-
- @SuppressWarnings("unchecked")
- public NotWrapSchema(Schema<?> schema) {
- this.schema = (Schema<Object>) schema;
- }
-
- @Override
- public Object readFromEmpty() {
- return null;
- }
-
- public Object readObject(Input input) throws IOException {
- Object value = schema.newMessage();
- schema.mergeFrom(input, value);
-
- return value;
- }
-
- public void writeObject(Output output, Object value) throws IOException {
- if (value == null) {
- return;
- }
-
- schema.writeTo(output, value);
- }
-}
diff --git a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/schema/WrapSchemaFactory.java b/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/schema/WrapSchemaFactory.java
deleted file mode 100644
index 30923aa..0000000
--- a/common/common-protobuf/src/main/java/org/apache/servicecomb/codec/protobuf/utils/schema/WrapSchemaFactory.java
+++ /dev/null
@@ -1,43 +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.codec.protobuf.utils.schema;
-
-import org.apache.servicecomb.codec.protobuf.utils.WrapSchema;
-import org.apache.servicecomb.codec.protobuf.utils.WrapType;
-
-import io.protostuff.Schema;
-
-public final class WrapSchemaFactory {
- public static WrapSchema createSchema(Schema<?> schema, WrapType type) {
- switch (type) {
- case NOT_WRAP:
- return new NotWrapSchema(schema);
- case NORMAL_WRAP:
- return new NormalWrapSchema(schema);
- case ARGS_NOT_WRAP:
- return new ArgsNotWrapSchema(schema);
- case ARGS_WRAP:
- return new ArgsWrapSchema(schema);
- default:
- throw new Error("impossible");
- }
- }
-
- private WrapSchemaFactory() {
- }
-}
diff --git a/common/common-protobuf/src/test/java/org/apache/servicecomb/codec/protobuf/utils/schema/TestArgsNotWrapSchema.java b/common/common-protobuf/src/test/java/org/apache/servicecomb/codec/protobuf/utils/schema/TestArgsNotWrapSchema.java
deleted file mode 100644
index a4c655e..0000000
--- a/common/common-protobuf/src/test/java/org/apache/servicecomb/codec/protobuf/utils/schema/TestArgsNotWrapSchema.java
+++ /dev/null
@@ -1,95 +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.codec.protobuf.utils.schema;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-
-import io.protostuff.Input;
-import io.protostuff.LinkedBuffer;
-import io.protostuff.ProtobufOutput;
-import io.protostuff.Schema;
-
-public class TestArgsNotWrapSchema {
-
- private ArgsNotWrapSchema argsNotWrapSchema = null;
-
- @Before
- public void setUp() throws Exception {
- argsNotWrapSchema = new ArgsNotWrapSchema(Mockito.mock(Schema.class));
- }
-
- @After
- public void tearDown() throws Exception {
- argsNotWrapSchema = null;
- }
-
- @Test
- public void testReadFromEmpty() {
- Assert.assertNotNull(argsNotWrapSchema);
- Object object = argsNotWrapSchema.readFromEmpty();
- Assert.assertNotNull(object);
- // object is created but no values inside to assert
- }
-
- @Test
- public void testReadObject() {
- boolean status = true;
- Input input = null;
- try {
- Object object = argsNotWrapSchema.readObject(input);
- Assert.assertNotNull(object);
- // object is created but no values inside to assert
- } catch (Exception e) {
- status = false;
- }
- Assert.assertTrue(status);
- }
-
- @Test
- public void testWriteObject() {
- boolean status = true;
- LinkedBuffer linkedBuffer = LinkedBuffer.allocate();
- ProtobufOutput output = new ProtobufOutput(linkedBuffer);
- String[] stringArray = new String[1];
- try {
- argsNotWrapSchema.writeObject(output, stringArray);
- } catch (Exception e) {
- status = false;
- }
- Assert.assertTrue(status);
- }
-
- @Test
- public void testWriteObjectToSchema() {
- boolean status = true;
- LinkedBuffer linkedBuffer = LinkedBuffer.allocate();
- ProtobufOutput output = new ProtobufOutput(linkedBuffer);
- String[] stringArray = new String[1];
- stringArray[0] = "abc";
- try {
- argsNotWrapSchema.writeObject(output, stringArray);
- } catch (Exception e) {
- status = false;
- }
- Assert.assertTrue(status);
- }
-}
diff --git a/common/common-protobuf/src/test/java/org/apache/servicecomb/codec/protobuf/utils/schema/TestArgsWrapSchema.java b/common/common-protobuf/src/test/java/org/apache/servicecomb/codec/protobuf/utils/schema/TestArgsWrapSchema.java
deleted file mode 100644
index ec8dcfc..0000000
--- a/common/common-protobuf/src/test/java/org/apache/servicecomb/codec/protobuf/utils/schema/TestArgsWrapSchema.java
+++ /dev/null
@@ -1,97 +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.codec.protobuf.utils.schema;
-
-import java.io.IOException;
-
-import org.apache.servicecomb.common.javassist.MultiWrapper;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-
-import io.protostuff.Input;
-import io.protostuff.LinkedBuffer;
-import io.protostuff.ProtobufOutput;
-import io.protostuff.Schema;
-
-public class TestArgsWrapSchema {
-
- private ArgsWrapSchema argsWrapSchema = null;
-
- @SuppressWarnings("rawtypes")
- private Schema schema = null;
-
- @Before
- public void setUp() throws Exception {
- schema = Mockito.mock(Schema.class);
- argsWrapSchema = new ArgsWrapSchema(schema);
- }
-
- @After
- public void tearDown() throws Exception {
- argsWrapSchema = null;
- }
-
- @Test
- public void testReadFromEmpty() {
-
- MultiWrapper multiWrapper = Mockito.mock(MultiWrapper.class);
- Mockito.when(schema.newMessage()).thenReturn(multiWrapper);
- Assert.assertNotNull(argsWrapSchema);
- Object object = argsWrapSchema.readFromEmpty();
- Assert.assertNull(object);
- }
-
- @Test
- public void testWriteObject() {
- boolean status = true;
- LinkedBuffer linkedBuffer = LinkedBuffer.allocate();
- ProtobufOutput output = new ProtobufOutput(linkedBuffer);
- String[] stringArray = new String[1];
- stringArray[0] = "abc";
-
- MultiWrapper multiWrapper = Mockito.mock(MultiWrapper.class);
- Mockito.when(schema.newMessage()).thenReturn(multiWrapper);
- try {
- argsWrapSchema.writeObject(output, stringArray);
- } catch (IOException e) {
- status = true;
- }
- Assert.assertTrue(status);
- }
-
- @Test
- public void testReadObject() {
- boolean status = true;
- Input input = null;
- String[] stringArray = new String[1];
- stringArray[0] = "abc";
-
- MultiWrapper multiWrapper = Mockito.mock(MultiWrapper.class);
- Mockito.when(schema.newMessage()).thenReturn(multiWrapper);
- try {
- Object object = argsWrapSchema.readObject(input);
- Assert.assertNull(object);
- } catch (IOException e) {
- status = true;
- }
- Assert.assertTrue(status);
- }
-}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/ProtoMapper.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/ProtoMapper.java
index cffc2d2..27815b5 100644
--- a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/ProtoMapper.java
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/ProtoMapper.java
@@ -33,6 +33,8 @@ import com.fasterxml.jackson.databind.type.TypeFactory;
import io.protostuff.compiler.model.Message;
import io.protostuff.compiler.model.Proto;
+import io.protostuff.compiler.model.Service;
+import io.protostuff.compiler.model.ServiceMethod;
public class ProtoMapper {
private final ObjectMapper jsonMapper;
@@ -97,6 +99,18 @@ public class ProtoMapper {
return null;
}
+ public Message getRequestMessage(String operationId) {
+ Service service = proto.getServices().get(0);
+ ServiceMethod serviceMethod = service.getMethod(operationId);
+ return serviceMethod.getArgType();
+ }
+
+ public Message getResponseMessage(String operationId) {
+ Service service = proto.getServices().get(0);
+ ServiceMethod serviceMethod = service.getMethod(operationId);
+ return serviceMethod.getReturnType();
+ }
+
public synchronized RootSerializer createRootSerializer(String shortMessageName, Type type) {
Message message = proto.getMessage(shortMessageName);
if (message == null) {
diff --git a/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/HighwayCodec.java b/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/HighwayCodec.java
index 5d7395d..71b8505 100644
--- a/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/HighwayCodec.java
+++ b/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/HighwayCodec.java
@@ -17,9 +17,12 @@
package org.apache.servicecomb.transport.highway;
+import java.util.Map;
+
import org.apache.servicecomb.codec.protobuf.definition.OperationProtobuf;
-import org.apache.servicecomb.codec.protobuf.utils.WrapSchema;
import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.foundation.protobuf.RootDeserializer;
+import org.apache.servicecomb.foundation.protobuf.RootSerializer;
import org.apache.servicecomb.foundation.vertx.client.tcp.TcpData;
import org.apache.servicecomb.foundation.vertx.tcp.TcpOutputStream;
import org.apache.servicecomb.swagger.invocation.Response;
@@ -44,14 +47,17 @@ public final class HighwayCodec {
header.setContext(invocation.getContext());
HighwayOutputStream os = new HighwayOutputStream(msgId);
- os.write(header, operationProtobuf.getRequestSchema(), invocation.getArgs());
+ // TODO: WEAK write array or map
+ os.write(header, operationProtobuf.findRequestSerializer(), invocation.getArgs());
return os;
}
+ @SuppressWarnings("rawtypes")
public static void decodeRequest(Invocation invocation, RequestHeader header, OperationProtobuf operationProtobuf,
Buffer bodyBuffer) throws Exception {
- WrapSchema schema = operationProtobuf.getRequestSchema();
- Object[] args = schema.readObject(bodyBuffer);
+ RootDeserializer<Map> schema = operationProtobuf.findRequestDesirializer();
+ // TODO: WEAK read array or map
+ Object[] args = schema.deserialize(bodyBuffer.getBytes()).values().toArray();
invocation.setSwaggerArguments(args);
invocation.mergeContext(header.getContext());
@@ -61,7 +67,7 @@ public final class HighwayCodec {
return RequestHeader.readObject(headerBuffer);
}
- public static Buffer encodeResponse(long msgId, ResponseHeader header, WrapSchema bodySchema,
+ public static Buffer encodeResponse(long msgId, ResponseHeader header, RootSerializer bodySchema,
Object body) throws Exception {
try (HighwayOutputStream os = new HighwayOutputStream(msgId)) {
os.write(header, bodySchema, body);
@@ -76,8 +82,8 @@ public final class HighwayCodec {
invocation.getContext().putAll(header.getContext());
}
- WrapSchema bodySchema = operationProtobuf.findResponseSchema(header.getStatusCode());
- Object body = bodySchema.readObject(tcpData.getBodyBuffer());
+ RootDeserializer<Object> bodySchema = operationProtobuf.findResponseDesirialize(header.getStatusCode());
+ Object body = bodySchema.deserialize(tcpData.getBodyBuffer().getBytes());
Response response = Response.create(header.getStatusCode(), header.getReasonPhrase(), body);
response.setHeaders(header.getHeaders());
diff --git a/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/HighwayOutputStream.java b/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/HighwayOutputStream.java
index e230397..0535eb1 100644
--- a/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/HighwayOutputStream.java
+++ b/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/HighwayOutputStream.java
@@ -16,7 +16,6 @@
*/
package org.apache.servicecomb.transport.highway;
-import org.apache.servicecomb.codec.protobuf.utils.WrapSchema;
import org.apache.servicecomb.foundation.protobuf.RootSerializer;
import org.apache.servicecomb.foundation.vertx.tcp.TcpOutputStream;
import org.apache.servicecomb.transport.highway.message.RequestHeader;
@@ -34,13 +33,7 @@ public class HighwayOutputStream extends TcpOutputStream {
write(RequestHeader.getRootSerializer(), header, bodySchema, body);
}
- public void write(RequestHeader header, WrapSchema bodySchema, Object body) throws Exception {
- // TODO : WEAK can be reomved
- write(RequestHeader.getRootSerializer(), header, bodySchema, body);
- }
-
- public void write(ResponseHeader header, WrapSchema bodySchema, Object body) throws Exception {
- // TODO : WEAK can be reomved
+ public void write(ResponseHeader header, RootSerializer bodySchema, Object body) throws Exception {
write(ResponseHeader.getRootSerializer(), header, bodySchema, body);
}
@@ -61,28 +54,4 @@ public class HighwayOutputStream extends TcpOutputStream {
bodySchema.serialize(this, body);
}
}
-
- public void write(RootSerializer headerSchema, Object header, WrapSchema bodySchema, Object body) throws Exception {
- // TODO : WEAK can be reomved
- // 写protobuf数据
- LinkedBuffer linkedBuffer = LinkedBuffer.allocate();
- ProtobufOutput output = new ProtobufOutput(linkedBuffer);
-
- // 写header
- if (headerSchema != null) {
- headerSchema.serialize(this, header);
- }
-
- // TODO : WEAK serialize message body
-// int headerSize = output.getSize();
-//
-// // 写body
-// // void时bodySchema为null
-// if (bodySchema != null) {
-// bodySchema.writeObject(output, body);
-// }
-//
-// writeLength(output.getSize(), headerSize);
-// LinkedBuffer.writeTo(this, linkedBuffer);
- }
}
diff --git a/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/HighwayServerInvoke.java b/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/HighwayServerInvoke.java
index 727eaef..c426a90 100644
--- a/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/HighwayServerInvoke.java
+++ b/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/HighwayServerInvoke.java
@@ -25,7 +25,6 @@ import javax.xml.ws.Holder;
import org.apache.servicecomb.codec.protobuf.definition.OperationProtobuf;
import org.apache.servicecomb.codec.protobuf.definition.ProtobufManager;
-import org.apache.servicecomb.codec.protobuf.utils.WrapSchema;
import org.apache.servicecomb.core.Const;
import org.apache.servicecomb.core.Endpoint;
import org.apache.servicecomb.core.Handler;
@@ -35,6 +34,7 @@ import org.apache.servicecomb.core.definition.MicroserviceMeta;
import org.apache.servicecomb.core.definition.OperationMeta;
import org.apache.servicecomb.core.definition.SchemaMeta;
import org.apache.servicecomb.core.invocation.InvocationFactory;
+import org.apache.servicecomb.foundation.protobuf.RootSerializer;
import org.apache.servicecomb.foundation.vertx.tcp.TcpConnection;
import org.apache.servicecomb.swagger.invocation.Response;
import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
@@ -143,7 +143,7 @@ public class HighwayServerInvoke {
header.setContext(context);
header.setHeaders(response.getHeaders());
- WrapSchema bodySchema = operationProtobuf.findResponseSchema(response.getStatusCode());
+ RootSerializer bodySchema = operationProtobuf.findResponseSerializer(response.getStatusCode());
Object body = response.getResult();
if (response.isFailed()) {
body = ((InvocationException) body).getErrorData();
diff --git a/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/message/LoginRequest.java b/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/message/LoginRequest.java
index 358c764..191153e 100644
--- a/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/message/LoginRequest.java
+++ b/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/message/LoginRequest.java
@@ -16,15 +16,10 @@
*/
package org.apache.servicecomb.transport.highway.message;
-import org.apache.servicecomb.codec.protobuf.definition.ProtobufManager;
-import org.apache.servicecomb.codec.protobuf.utils.ScopedProtobufSchemaManager;
-import org.apache.servicecomb.codec.protobuf.utils.WrapSchema;
import org.apache.servicecomb.foundation.protobuf.ProtoMapperFactory;
import org.apache.servicecomb.foundation.protobuf.RootDeserializer;
import org.apache.servicecomb.foundation.protobuf.RootSerializer;
-import io.protostuff.ProtobufOutput;
-import io.protostuff.Tag;
import io.vertx.core.buffer.Buffer;
public class LoginRequest {
diff --git a/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayCodec.java b/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayCodec.java
index b2f1de8..5142620 100644
--- a/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayCodec.java
+++ b/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayCodec.java
@@ -17,28 +17,20 @@
package org.apache.servicecomb.transport.highway;
-import java.io.IOException;
import java.nio.ByteBuffer;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
import org.apache.servicecomb.codec.protobuf.definition.OperationProtobuf;
-import org.apache.servicecomb.codec.protobuf.utils.WrapSchema;
-import org.apache.servicecomb.codec.protobuf.utils.schema.NotWrapSchema;
import org.apache.servicecomb.core.Endpoint;
import org.apache.servicecomb.core.Invocation;
import org.apache.servicecomb.core.definition.OperationMeta;
import org.apache.servicecomb.core.definition.SchemaMeta;
-import org.apache.servicecomb.foundation.vertx.client.tcp.TcpData;
+import org.apache.servicecomb.foundation.protobuf.RootSerializer;
import org.apache.servicecomb.foundation.vertx.server.TcpParser;
import org.apache.servicecomb.foundation.vertx.tcp.TcpOutputStream;
import org.apache.servicecomb.serviceregistry.RegistryUtils;
import org.apache.servicecomb.serviceregistry.ServiceRegistry;
import org.apache.servicecomb.serviceregistry.registry.ServiceRegistryFactory;
-import org.apache.servicecomb.swagger.invocation.Response;
import org.apache.servicecomb.transport.highway.message.RequestHeader;
-import org.apache.servicecomb.transport.highway.message.ResponseHeader;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -47,11 +39,8 @@ import org.junit.Test;
import org.mockito.Mockito;
import io.netty.buffer.ByteBuf;
-import io.protostuff.Input;
import io.protostuff.runtime.ProtobufCompatibleUtils;
import io.vertx.core.buffer.Buffer;
-import mockit.Mock;
-import mockit.MockUp;
import mockit.Mocked;
public class TestHighwayCodec {
@@ -62,7 +51,7 @@ public class TestHighwayCodec {
private Buffer bodyBuffer = null;
- private WrapSchema schema = null;
+ private RootSerializer requestSerializer = null;
private SchemaMeta schemaMeta = null;
@@ -91,7 +80,7 @@ public class TestHighwayCodec {
bodyBuffer = Mockito.mock(Buffer.class);
- schema = Mockito.mock(WrapSchema.class);
+ requestSerializer = Mockito.mock(RootSerializer.class);
schemaMeta = Mockito.mock(SchemaMeta.class);
@@ -113,7 +102,7 @@ public class TestHighwayCodec {
bodyBuffer = null;
- schema = null;
+ requestSerializer = null;
schemaMeta = null;
@@ -191,7 +180,7 @@ public class TestHighwayCodec {
@Test
public void testEncodeResponse() {
boolean status = true;
- WrapSchema bodySchema = Mockito.mock(WrapSchema.class);
+ RootSerializer bodySchema = Mockito.mock(RootSerializer.class);
try {
commonMock();
HighwayCodec.encodeResponse(23432142, null, bodySchema, new Object());
@@ -237,7 +226,7 @@ public class TestHighwayCodec {
}
private void commonMock() {
- Mockito.when(operationProtobuf.getRequestSchema()).thenReturn(schema);
+ Mockito.when(operationProtobuf.findRequestSerializer()).thenReturn(requestSerializer);
Mockito.when(bodyBuffer.getByteBuf()).thenReturn(lByteBuf);
Mockito.when(lByteBuf.nioBuffer()).thenReturn(nioBuffer);
Mockito.when(operationProtobuf.getOperationMeta()).thenReturn(operationMeta);
diff --git a/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayServerConnection.java b/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayServerConnection.java
index eed5aaf..d8ed159 100644
--- a/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayServerConnection.java
+++ b/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayServerConnection.java
@@ -16,36 +16,6 @@
*/
package org.apache.servicecomb.transport.highway;
-import java.net.InetSocketAddress;
-
-import javax.xml.ws.Holder;
-
-import org.apache.servicecomb.codec.protobuf.definition.ProtobufManager;
-import org.apache.servicecomb.codec.protobuf.utils.ScopedProtobufSchemaManager;
-import org.apache.servicecomb.codec.protobuf.utils.WrapSchema;
-import org.apache.servicecomb.core.Endpoint;
-import org.apache.servicecomb.core.SCBEngine;
-import org.apache.servicecomb.core.definition.MicroserviceMeta;
-import org.apache.servicecomb.core.definition.OperationMeta;
-import org.apache.servicecomb.core.definition.SchemaMeta;
-import org.apache.servicecomb.foundation.vertx.stream.BufferOutputStream;
-import org.apache.servicecomb.transport.highway.message.LoginRequest;
-import org.apache.servicecomb.transport.highway.message.RequestHeader;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import io.protostuff.LinkedBuffer;
-import io.protostuff.ProtobufOutput;
-import io.vertx.core.buffer.Buffer;
-import io.vertx.core.net.NetSocket;
-import io.vertx.core.net.impl.NetSocketImpl;
-import io.vertx.core.net.impl.SocketAddressImpl;
-import mockit.Expectations;
-import mockit.Mock;
-import mockit.MockUp;
-import mockit.Mocked;
-
public class TestHighwayServerConnection {
// TODO : WK unit test
// private static WrapSchema requestHeaderSchema =
diff --git a/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayTransport.java b/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayTransport.java
index 63e493e..6c27df9 100644
--- a/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayTransport.java
+++ b/transports/transport-highway/src/test/java/org/apache/servicecomb/transport/highway/TestHighwayTransport.java
@@ -20,11 +20,11 @@ package org.apache.servicecomb.transport.highway;
import javax.xml.ws.Holder;
import org.apache.servicecomb.codec.protobuf.definition.OperationProtobuf;
-import org.apache.servicecomb.codec.protobuf.utils.WrapSchema;
import org.apache.servicecomb.core.Endpoint;
import org.apache.servicecomb.core.Invocation;
import org.apache.servicecomb.core.definition.OperationMeta;
import org.apache.servicecomb.foundation.common.net.URIEndpointObject;
+import org.apache.servicecomb.foundation.protobuf.RootSerializer;
import org.apache.servicecomb.foundation.vertx.VertxUtils;
import org.apache.servicecomb.swagger.invocation.AsyncResponse;
import org.junit.AfterClass;
@@ -46,13 +46,13 @@ public class TestHighwayTransport {
@BeforeClass
public static void setup() {
VertxUtils.blockCloseVertxByName("transport");
- Thread.getAllStackTraces().keySet().forEach(t->LOGGER.info("before: {}", t.getName()));
+ Thread.getAllStackTraces().keySet().forEach(t -> LOGGER.info("before: {}", t.getName()));
}
@AfterClass
public static void teardown() {
VertxUtils.blockCloseVertxByName("transport");
- Thread.getAllStackTraces().keySet().forEach(t->LOGGER.info("after: {}", t.getName()));
+ Thread.getAllStackTraces().keySet().forEach(t -> LOGGER.info("after: {}", t.getName()));
}
@Test
@@ -103,8 +103,8 @@ public class TestHighwayTransport {
Mockito.when(operationMeta.getExtData("protobuf")).thenReturn(operationProtobuf);
Endpoint lEndpoint = Mockito.mock(Endpoint.class);
Mockito.when(invocation.getEndpoint()).thenReturn(lEndpoint);
- WrapSchema lWrapSchema = Mockito.mock(WrapSchema.class);
- Mockito.when(operationProtobuf.getRequestSchema()).thenReturn(lWrapSchema);
+ RootSerializer lWrapSchema = Mockito.mock(RootSerializer.class);
+ Mockito.when(operationProtobuf.findRequestSerializer()).thenReturn(lWrapSchema);
URIEndpointObject ep = Mockito.mock(URIEndpointObject.class);
Mockito.when(lEndpoint.getAddress()).thenReturn(ep);
Mockito.when(ep.getHostOrIp()).thenReturn("127.0.0.1");