Clean up warnings in spring-web

This commit is contained in:
Sam Brannen
2019-05-10 17:07:12 +02:00
parent f188aab5f2
commit 9b61316c2e
15 changed files with 24 additions and 33 deletions

View File

@@ -61,6 +61,7 @@ public class ServerSentEventHttpMessageReaderTests extends AbstractLeakCheckingT
}
@Test
@SuppressWarnings("rawtypes")
public void readServerSentEvents() {
MockServerHttpRequest request = MockServerHttpRequest.post("/")
.body(Mono.just(stringBuffer(
@@ -91,6 +92,7 @@ public class ServerSentEventHttpMessageReaderTests extends AbstractLeakCheckingT
}
@Test
@SuppressWarnings("rawtypes")
public void readServerSentEventsWithMultipleChunks() {
MockServerHttpRequest request = MockServerHttpRequest.post("/")
.body(Flux.just(
@@ -199,5 +201,4 @@ public class ServerSentEventHttpMessageReaderTests extends AbstractLeakCheckingT
return buffer;
}
}

View File

@@ -215,6 +215,7 @@ public class Jackson2JsonDecoderTests extends AbstractDecoderTestCase<Jackson2Js
}
@SuppressWarnings("unused")
private static class BeanWithNoDefaultConstructor {
private final String property1;

View File

@@ -271,7 +271,8 @@ public class MultipartHttpMessageWriterTests extends AbstractLeakCheckingTestCas
}
private class Foo {
@SuppressWarnings("unused")
private static class Foo {
private String bar;

View File

@@ -651,6 +651,7 @@ public class Jackson2ObjectMapperBuilderTests {
public static class JacksonVisibilityBean {
@SuppressWarnings("unused")
private String property1;
public String property2;

View File

@@ -614,6 +614,7 @@ public class MappingJackson2HttpMessageConverterTests {
}
@SuppressWarnings("unused")
private static class BeanWithNoDefaultConstructor {
private final String property1;

View File

@@ -21,7 +21,6 @@ import java.io.IOException;
import com.google.protobuf.ExtensionRegistry;
import com.google.protobuf.Message;
import com.google.protobuf.util.JsonFormat;
import org.junit.Before;
import org.junit.Test;
import org.springframework.http.MediaType;
@@ -47,23 +46,12 @@ import static org.mockito.Mockito.verify;
@SuppressWarnings("deprecation")
public class ProtobufJsonFormatHttpMessageConverterTests {
private ProtobufHttpMessageConverter converter;
private final ExtensionRegistryInitializer registryInitializer = mock(ExtensionRegistryInitializer.class);
private ExtensionRegistry extensionRegistry;
private final ProtobufHttpMessageConverter converter = new ProtobufJsonFormatHttpMessageConverter(
JsonFormat.parser(), JsonFormat.printer(), this.registryInitializer);
private ExtensionRegistryInitializer registryInitializer;
private Msg testMsg;
@Before
public void setup() {
this.registryInitializer = mock(ExtensionRegistryInitializer.class);
this.extensionRegistry = mock(ExtensionRegistry.class);
this.converter = new ProtobufJsonFormatHttpMessageConverter(
JsonFormat.parser(), JsonFormat.printer(), this.registryInitializer);
this.testMsg = Msg.newBuilder().setFoo("Foo").setBlah(SecondMsg.newBuilder().setBlah(123).build()).build();
}
private final Msg testMsg = Msg.newBuilder().setFoo("Foo").setBlah(SecondMsg.newBuilder().setBlah(123).build()).build();
@Test

View File

@@ -253,6 +253,7 @@ public class WebExchangeDataBinderTests {
}
}
@SuppressWarnings("unused")
private static class MultipartBean {
private String name;

View File

@@ -49,7 +49,7 @@ public class ExtractingResponseErrorHandlerTests {
@Before
public void setup() throws Exception {
public void setup() {
HttpMessageConverter<Object> converter = new MappingJackson2HttpMessageConverter();
this.errorHandler = new ExtractingResponseErrorHandler(
Collections.singletonList(converter));
@@ -184,9 +184,6 @@ public class ExtractingResponseErrorHandlerTests {
return this.foo;
}
public void setFoo(String foo) {
this.foo = foo;
}
}
}

View File

@@ -222,11 +222,11 @@ public class RestTemplateTests {
@Test
public void requestAvoidsDuplicateAcceptHeaderValues() throws Exception {
HttpMessageConverter firstConverter = mock(HttpMessageConverter.class);
HttpMessageConverter<?> firstConverter = mock(HttpMessageConverter.class);
given(firstConverter.canRead(any(), any())).willReturn(true);
given(firstConverter.getSupportedMediaTypes())
.willReturn(Collections.singletonList(MediaType.TEXT_PLAIN));
HttpMessageConverter secondConverter = mock(HttpMessageConverter.class);
HttpMessageConverter<?> secondConverter = mock(HttpMessageConverter.class);
given(secondConverter.canRead(any(), any())).willReturn(true);
given(secondConverter.getSupportedMediaTypes())
.willReturn(Collections.singletonList(MediaType.TEXT_PLAIN));
@@ -704,7 +704,7 @@ public class RestTemplateTests {
mockHttpMessageConverter(MediaType.TEXT_PLAIN, String.class);
}
private void mockHttpMessageConverter(MediaType mediaType, Class type) {
private void mockHttpMessageConverter(MediaType mediaType, Class<?> type) {
given(converter.canRead(type, null)).willReturn(true);
given(converter.canRead(type, mediaType)).willReturn(true);
given(converter.getSupportedMediaTypes())

View File

@@ -154,8 +154,8 @@ public class WebAsyncManagerTimeoutTests {
verify(interceptor).beforeConcurrentHandling(this.asyncWebRequest, callable);
}
@SuppressWarnings("unchecked")
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void startCallableProcessingTimeoutAndCheckThreadInterrupted() throws Exception {
StubCallable callable = new StubCallable();

View File

@@ -612,7 +612,7 @@ public class RequestParamMethodArgumentResolverTests {
@RequestParam(name = "name", required = false) String paramNotRequired,
@RequestParam("name") Optional<Integer> paramOptional,
@RequestParam("name") Optional<Integer[]> paramOptionalArray,
@RequestParam("name") Optional<List> paramOptionalList,
@RequestParam("name") Optional<List<?>> paramOptionalList,
@RequestParam("mfile") Optional<MultipartFile> multipartFileOptional) {
}