Fixing compatibility issues between netflix and openfeign as well as boot 1.5.x and 2.0.x
This commit is contained in:
@@ -14,17 +14,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.netflix.feign.encoding.proto;
|
||||
package org.springframework.cloud.openfeign.encoding.proto;
|
||||
|
||||
import feign.RequestTemplate;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.ObjectFactory;
|
||||
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
|
||||
import org.springframework.cloud.ClassPathExclusions;
|
||||
import org.springframework.cloud.FilteredClassPathRunner;
|
||||
import org.springframework.cloud.netflix.feign.support.SpringEncoder;
|
||||
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
|
||||
import org.springframework.cloud.openfeign.support.SpringEncoder;
|
||||
import org.springframework.cloud.test.ClassPathExclusions;
|
||||
import org.springframework.cloud.test.ModifiedClassPathRunner;
|
||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||
|
||||
/**
|
||||
@@ -32,7 +32,7 @@ import org.springframework.http.converter.StringHttpMessageConverter;
|
||||
*
|
||||
* @author ScienJus
|
||||
*/
|
||||
@RunWith(FilteredClassPathRunner.class)
|
||||
@RunWith(ModifiedClassPathRunner.class)
|
||||
@ClassPathExclusions("protobuf-*.jar")
|
||||
public class ProtobufNotInClasspathTest {
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.netflix.feign.encoding.proto;
|
||||
package org.springframework.cloud.openfeign.encoding.proto;
|
||||
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import feign.RequestTemplate;
|
||||
@@ -38,8 +38,8 @@ import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.ObjectFactory;
|
||||
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
|
||||
import org.springframework.cloud.netflix.feign.support.SpringEncoder;
|
||||
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
|
||||
import org.springframework.cloud.openfeign.support.SpringEncoder;
|
||||
import org.springframework.http.converter.protobuf.ProtobufHttpMessageConverter;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -61,7 +61,7 @@ public class ProtobufSpringEncoderTest {
|
||||
private HttpClient httpClient;
|
||||
|
||||
// a protobuf object with some content
|
||||
private Request request = Request.newBuilder()
|
||||
private org.springframework.cloud.openfeign.encoding.proto.Request request = org.springframework.cloud.openfeign.encoding.proto.Request.newBuilder()
|
||||
.setId(1000000)
|
||||
.setMsg("Erlang/OTP 最初是爱立信为开发电信设备系统设计的编程语言平台," +
|
||||
"电信设备(路由器、接入网关、…)典型设计是通过背板连接主控板卡与多块业务板卡的分布式系统。")
|
||||
@@ -76,7 +76,7 @@ public class ProtobufSpringEncoderTest {
|
||||
byte[] bytes = read(entity.getContent(), (int) entity.getContentLength());
|
||||
|
||||
Assert.assertArrayEquals(bytes, request.toByteArray());
|
||||
Request copy = Request.parseFrom(bytes);
|
||||
org.springframework.cloud.openfeign.encoding.proto.Request copy = org.springframework.cloud.openfeign.encoding.proto.Request.parseFrom(bytes);
|
||||
Assert.assertEquals(request, copy);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public class ProtobufSpringEncoderTest {
|
||||
// http request-body is different with original protobuf body
|
||||
Assert.assertNotEquals(bytes.length, request.toByteArray().length);
|
||||
try {
|
||||
Request copy = Request.parseFrom(bytes);
|
||||
org.springframework.cloud.openfeign.encoding.proto.Request copy = org.springframework.cloud.openfeign.encoding.proto.Request.parseFrom(bytes);
|
||||
Assert.fail("Expected an InvalidProtocolBufferException to be thrown");
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
// success
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: protobuf_test.proto
|
||||
|
||||
package org.springframework.cloud.netflix.feign.encoding.proto;
|
||||
package org.springframework.cloud.openfeign.encoding.proto;
|
||||
|
||||
public final class ProtobufTest {
|
||||
private ProtobufTest() {}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: protobuf_test.proto
|
||||
|
||||
package org.springframework.cloud.netflix.feign.encoding.proto;
|
||||
package org.springframework.cloud.openfeign.encoding.proto;
|
||||
|
||||
/**
|
||||
* Protobuf type {@code Request}
|
||||
@@ -25,7 +25,7 @@ package org.springframework.cloud.netflix.feign.encoding.proto;
|
||||
public final class Request extends
|
||||
com.google.protobuf.GeneratedMessageV3 implements
|
||||
// @@protoc_insertion_point(message_implements:Request)
|
||||
RequestOrBuilder {
|
||||
org.springframework.cloud.openfeign.encoding.proto.RequestOrBuilder {
|
||||
private static final long serialVersionUID = 0L;
|
||||
// Use Request.newBuilder() to construct.
|
||||
private Request(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
|
||||
@@ -89,12 +89,12 @@ private static final long serialVersionUID = 0L;
|
||||
}
|
||||
public static final com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return ProtobufTest.internal_static_Request_descriptor;
|
||||
return org.springframework.cloud.openfeign.encoding.proto.ProtobufTest.internal_static_Request_descriptor;
|
||||
}
|
||||
|
||||
protected FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return ProtobufTest.internal_static_Request_fieldAccessorTable
|
||||
return org.springframework.cloud.openfeign.encoding.proto.ProtobufTest.internal_static_Request_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
Request.class, Request.Builder.class);
|
||||
}
|
||||
@@ -309,20 +309,20 @@ private static final long serialVersionUID = 0L;
|
||||
public static final class Builder extends
|
||||
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
|
||||
// @@protoc_insertion_point(builder_implements:Request)
|
||||
RequestOrBuilder {
|
||||
org.springframework.cloud.openfeign.encoding.proto.RequestOrBuilder {
|
||||
public static final com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptor() {
|
||||
return ProtobufTest.internal_static_Request_descriptor;
|
||||
return org.springframework.cloud.openfeign.encoding.proto.ProtobufTest.internal_static_Request_descriptor;
|
||||
}
|
||||
|
||||
protected FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return ProtobufTest.internal_static_Request_fieldAccessorTable
|
||||
return org.springframework.cloud.openfeign.encoding.proto.ProtobufTest.internal_static_Request_fieldAccessorTable
|
||||
.ensureFieldAccessorsInitialized(
|
||||
Request.class, Request.Builder.class);
|
||||
}
|
||||
|
||||
// Construct using org.springframework.cloud.netflix.feign.encoding.proto.Request.newBuilder()
|
||||
// Construct using org.springframework.cloud.openfeign.encoding.proto.Request.newBuilder()
|
||||
private Builder() {
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
@@ -348,7 +348,7 @@ private static final long serialVersionUID = 0L;
|
||||
|
||||
public com.google.protobuf.Descriptors.Descriptor
|
||||
getDescriptorForType() {
|
||||
return ProtobufTest.internal_static_Request_descriptor;
|
||||
return org.springframework.cloud.openfeign.encoding.proto.ProtobufTest.internal_static_Request_descriptor;
|
||||
}
|
||||
|
||||
public Request getDefaultInstanceForType() {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: protobuf_test.proto
|
||||
|
||||
package org.springframework.cloud.netflix.feign.encoding.proto;
|
||||
package org.springframework.cloud.openfeign.encoding.proto;
|
||||
|
||||
public interface RequestOrBuilder extends
|
||||
// @@protoc_insertion_point(interface_extends:Request)
|
||||
|
||||
Reference in New Issue
Block a user