Remove support for Protobuf 2.x and protobuf-java-format

Closes gh-31465
This commit is contained in:
Brian Clozel
2023-10-20 15:05:02 +02:00
parent 7271dfed68
commit 631a5d1dc1
4 changed files with 7 additions and 131 deletions

View File

@@ -55,11 +55,7 @@ class ProtobufHttpMessageConverterTests {
assertThat(this.converter.canRead(Msg.class, null)).isTrue();
assertThat(this.converter.canRead(Msg.class, ProtobufHttpMessageConverter.PROTOBUF)).isTrue();
assertThat(this.converter.canRead(Msg.class, MediaType.APPLICATION_JSON)).isTrue();
assertThat(this.converter.canRead(Msg.class, MediaType.APPLICATION_XML)).isTrue();
assertThat(this.converter.canRead(Msg.class, MediaType.TEXT_PLAIN)).isTrue();
// only supported as an output format
assertThat(this.converter.canRead(Msg.class, MediaType.TEXT_HTML)).isFalse();
}
@Test
@@ -67,9 +63,7 @@ class ProtobufHttpMessageConverterTests {
assertThat(this.converter.canWrite(Msg.class, null)).isTrue();
assertThat(this.converter.canWrite(Msg.class, ProtobufHttpMessageConverter.PROTOBUF)).isTrue();
assertThat(this.converter.canWrite(Msg.class, MediaType.APPLICATION_JSON)).isTrue();
assertThat(this.converter.canWrite(Msg.class, MediaType.APPLICATION_XML)).isTrue();
assertThat(this.converter.canWrite(Msg.class, MediaType.TEXT_PLAIN)).isTrue();
assertThat(this.converter.canWrite(Msg.class, MediaType.TEXT_HTML)).isTrue();
}
@Test
@@ -131,31 +125,6 @@ class ProtobufHttpMessageConverterTests {
ProtobufHttpMessageConverter.X_PROTOBUF_SCHEMA_HEADER)).isNull();
}
@Test
void writeJsonWithJavaFormat() throws IOException {
this.converter = new ProtobufHttpMessageConverter(
new ProtobufHttpMessageConverter.ProtobufJavaFormatSupport(),
this.extensionRegistry);
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
@SuppressWarnings("deprecation")
MediaType contentType = MediaType.APPLICATION_JSON_UTF8;
this.converter.write(this.testMsg, contentType, outputMessage);
assertThat(outputMessage.getHeaders().getContentType()).isEqualTo(contentType);
String body = outputMessage.getBodyAsString(StandardCharsets.UTF_8);
assertThat(body).as("body is empty").isNotEmpty();
Msg.Builder builder = Msg.newBuilder();
JsonFormat.parser().merge(body, builder);
assertThat(builder.build()).isEqualTo(this.testMsg);
assertThat(outputMessage.getHeaders().getFirst(
ProtobufHttpMessageConverter.X_PROTOBUF_MESSAGE_HEADER)).isNull();
assertThat(outputMessage.getHeaders().getFirst(
ProtobufHttpMessageConverter.X_PROTOBUF_SCHEMA_HEADER)).isNull();
}
@Test
void defaultContentType() throws Exception {
assertThat(this.converter.getDefaultContentType(this.testMsg))