Polishing contribution
Closes gh-34645
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,6 +33,7 @@ public abstract class ProtobufCodecSupport {
|
||||
|
||||
static final MimeType[] MIME_TYPES = new MimeType[]{
|
||||
new MimeType("application", "x-protobuf"),
|
||||
new MimeType("application", "*+x-protobuf"),
|
||||
new MimeType("application", "octet-stream"),
|
||||
new MimeType("application", "vnd.google.protobuf")
|
||||
};
|
||||
|
||||
@@ -70,6 +70,7 @@ class ProtobufDecoderTests extends AbstractDecoderTests<ProtobufDecoder> {
|
||||
public void canDecode() {
|
||||
assertThat(this.decoder.canDecode(forClass(Msg.class), null)).isTrue();
|
||||
assertThat(this.decoder.canDecode(forClass(Msg.class), MediaType.APPLICATION_PROTOBUF)).isTrue();
|
||||
assertThat(this.decoder.canDecode(forClass(Msg.class), MediaType.parseMediaType("application/vnd.example.public.v1+x-protobuf"))).isTrue();
|
||||
assertThat(this.decoder.canDecode(forClass(Msg.class), MediaType.APPLICATION_OCTET_STREAM)).isTrue();
|
||||
assertThat(this.decoder.canDecode(forClass(Msg.class), MediaType.APPLICATION_JSON)).isFalse();
|
||||
assertThat(this.decoder.canDecode(forClass(Object.class), MediaType.APPLICATION_PROTOBUF)).isFalse();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -45,10 +45,10 @@ class ProtobufEncoderTests extends AbstractEncoderTests<ProtobufEncoder> {
|
||||
|
||||
private static final MimeType PROTOBUF_MIME_TYPE = new MimeType("application", "x-protobuf");
|
||||
|
||||
private Msg msg1 =
|
||||
private final Msg msg1 =
|
||||
Msg.newBuilder().setFoo("Foo").setBlah(SecondMsg.newBuilder().setBlah(123).build()).build();
|
||||
|
||||
private Msg msg2 =
|
||||
private final Msg msg2 =
|
||||
Msg.newBuilder().setFoo("Bar").setBlah(SecondMsg.newBuilder().setBlah(456).build()).build();
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ class ProtobufEncoderTests extends AbstractEncoderTests<ProtobufEncoder> {
|
||||
protected void canEncode() {
|
||||
assertThat(this.encoder.canEncode(forClass(Msg.class), null)).isTrue();
|
||||
assertThat(this.encoder.canEncode(forClass(Msg.class), PROTOBUF_MIME_TYPE)).isTrue();
|
||||
assertThat(this.encoder.canEncode(forClass(Msg.class), MediaType.parseMediaType("application/vnd.example.public.v1+x-protobuf"))).isTrue();
|
||||
assertThat(this.encoder.canEncode(forClass(Msg.class), MediaType.APPLICATION_OCTET_STREAM)).isTrue();
|
||||
assertThat(this.encoder.canEncode(forClass(Msg.class), MediaType.APPLICATION_JSON)).isFalse();
|
||||
assertThat(this.encoder.canEncode(forClass(Object.class), PROTOBUF_MIME_TYPE)).isFalse();
|
||||
|
||||
@@ -45,10 +45,10 @@ class ProtobufHttpMessageConverterTests {
|
||||
|
||||
private ProtobufHttpMessageConverter converter = new ProtobufHttpMessageConverter();
|
||||
|
||||
private ExtensionRegistry extensionRegistry = mock();
|
||||
private final ExtensionRegistry extensionRegistry = mock();
|
||||
|
||||
private Msg testMsg = Msg.newBuilder().setFoo("Foo").setBlah(SecondMsg.newBuilder().setBlah(123).build()).build();
|
||||
private MediaType testPlusProtoMediaType = MediaType.parseMediaType("application/vnd.example.public.v1+x-protobuf");
|
||||
private final Msg testMsg = Msg.newBuilder().setFoo("Foo").setBlah(SecondMsg.newBuilder().setBlah(123).build()).build();
|
||||
private final MediaType testPlusProtoMediaType = MediaType.parseMediaType("application/vnd.example.public.v1+x-protobuf");
|
||||
|
||||
|
||||
@Test
|
||||
|
||||
@@ -42,7 +42,7 @@ class ProtobufJsonFormatHttpMessageConverterTests {
|
||||
JsonFormat.parser(), JsonFormat.printer());
|
||||
|
||||
private final Msg testMsg = Msg.newBuilder().setFoo("Foo").setBlah(SecondMsg.newBuilder().setBlah(123).build()).build();
|
||||
private MediaType testPlusProtoMediaType = MediaType.parseMediaType("application/vnd.examle.public.v1+x-protobuf");
|
||||
private final MediaType testPlusProtoMediaType = MediaType.parseMediaType("application/vnd.example.public.v1+x-protobuf");
|
||||
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user