Browse Source

Clean up warnings and delete dead code

pull/1925/head
Sam Brannen 8 years ago
parent
commit
cfb1ed1009
  1. 2
      spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationDrivenBeanDefinitionParserTests.java
  2. 1
      spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/ValidatorFactoryTests.java
  3. 20
      spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandlerTests.java
  4. 2
      spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java
  5. 1
      spring-orm/src/test/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryIntegrationTests.java
  6. 2
      spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateNativeEntityManagerFactoryIntegrationTests.java
  7. 4
      spring-oxm/src/test/java/org/springframework/oxm/AbstractUnmarshallerTests.java
  8. 5
      spring-web/src/test/java/org/springframework/http/ResponseCookieTests.java
  9. 1
      spring-web/src/test/java/org/springframework/http/converter/FormHttpMessageConverterTests.java
  10. 1
      spring-web/src/test/java/org/springframework/web/cors/reactive/UrlBasedCorsConfigurationSourceTests.java
  11. 4
      spring-web/src/test/java/org/springframework/web/util/UriComponentsTests.java
  12. 4
      spring-webflux/src/main/java/org/springframework/web/reactive/DispatcherHandler.java
  13. 1
      spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyExtractorsTests.java
  14. 1
      spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java
  15. 1
      spring-webflux/src/test/java/org/springframework/web/reactive/function/client/support/ClientResponseWrapperTests.java
  16. 1
      spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapperTests.java
  17. 1
      spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ServerWebExchangeArgumentResolverTests.java
  18. 2
      spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/view/script/ScriptTemplateWithBindingsExtensions.kt
  19. 6
      spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandler.java
  20. 1
      spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java
  21. 20
      spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java
  22. 1
      spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessorTests.java
  23. 2
      spring-webmvc/src/test/kotlin/org/springframework/web/servlet/view/script/ScriptTemplateWithBindingsExtensions.kt
  24. 1
      spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java
  25. 1
      spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/HttpReceivingTransportHandlerTests.java

2
spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationDrivenBeanDefinitionParserTests.java

@ -55,6 +55,7 @@ public class AnnotationDrivenBeanDefinitionParserTests { @@ -55,6 +55,7 @@ public class AnnotationDrivenBeanDefinitionParserTests {
}
@Test
@SuppressWarnings("rawtypes")
public void asyncPostProcessorExecutorReference() {
Object executor = context.getBean("testExecutor");
Object aspect = context.getBean(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME);
@ -62,6 +63,7 @@ public class AnnotationDrivenBeanDefinitionParserTests { @@ -62,6 +63,7 @@ public class AnnotationDrivenBeanDefinitionParserTests {
}
@Test
@SuppressWarnings("rawtypes")
public void asyncPostProcessorExceptionHandlerReference() {
Object exceptionHandler = context.getBean("testExceptionHandler");
Object aspect = context.getBean(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME);

1
spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/ValidatorFactoryTests.java

@ -284,7 +284,6 @@ public class ValidatorFactoryTests { @@ -284,7 +284,6 @@ public class ValidatorFactoryTests {
errors.initConversion(new DefaultConversionService());
validator.validate(listContainer, errors);
FieldError fieldError = errors.getFieldError("list[1]");
assertEquals("X", errors.getFieldValue("list[1]"));
}

20
spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandlerTests.java

@ -42,7 +42,6 @@ import org.springframework.lang.Nullable; @@ -42,7 +42,6 @@ import org.springframework.lang.Nullable;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.SubscribableChannel;
import org.springframework.messaging.converter.MessageConverter;
import org.springframework.messaging.handler.HandlerMethod;
@ -267,9 +266,9 @@ public class SimpAnnotationMethodMessageHandlerTests { @@ -267,9 +266,9 @@ public class SimpAnnotationMethodMessageHandlerTests {
}
@Test
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
public void listenableFutureSuccess() {
Message emptyMessage = (Message) MessageBuilder.withPayload(new byte[0]).build();
Message emptyMessage = MessageBuilder.withPayload(new byte[0]).build();
given(this.channel.send(any(Message.class))).willReturn(true);
given(this.converter.toMessage(any(), any(MessageHeaders.class))).willReturn(emptyMessage);
@ -287,9 +286,9 @@ public class SimpAnnotationMethodMessageHandlerTests { @@ -287,9 +286,9 @@ public class SimpAnnotationMethodMessageHandlerTests {
}
@Test
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
public void listenableFutureFailure() {
Message emptyMessage = (Message) MessageBuilder.withPayload(new byte[0]).build();
Message emptyMessage = MessageBuilder.withPayload(new byte[0]).build();
given(this.channel.send(any(Message.class))).willReturn(true);
given(this.converter.toMessage(any(), any(MessageHeaders.class))).willReturn(emptyMessage);
@ -305,9 +304,9 @@ public class SimpAnnotationMethodMessageHandlerTests { @@ -305,9 +304,9 @@ public class SimpAnnotationMethodMessageHandlerTests {
}
@Test
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
public void completableFutureSuccess() {
Message emptyMessage = (Message) MessageBuilder.withPayload(new byte[0]).build();
Message emptyMessage = MessageBuilder.withPayload(new byte[0]).build();
given(this.channel.send(any(Message.class))).willReturn(true);
given(this.converter.toMessage(any(), any(MessageHeaders.class))).willReturn(emptyMessage);
@ -325,9 +324,9 @@ public class SimpAnnotationMethodMessageHandlerTests { @@ -325,9 +324,9 @@ public class SimpAnnotationMethodMessageHandlerTests {
}
@Test
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
public void completableFutureFailure() {
Message emptyMessage = (Message) MessageBuilder.withPayload(new byte[0]).build();
Message emptyMessage = MessageBuilder.withPayload(new byte[0]).build();
given(this.channel.send(any(Message.class))).willReturn(true);
given(this.converter.toMessage(any(), any(MessageHeaders.class))).willReturn(emptyMessage);
@ -343,6 +342,7 @@ public class SimpAnnotationMethodMessageHandlerTests { @@ -343,6 +342,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
}
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void monoSuccess() {
Message emptyMessage = MessageBuilder.withPayload(new byte[0]).build();
given(this.channel.send(any(Message.class))).willReturn(true);
@ -362,6 +362,7 @@ public class SimpAnnotationMethodMessageHandlerTests { @@ -362,6 +362,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
}
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void monoFailure() {
Message emptyMessage = MessageBuilder.withPayload(new byte[0]).build();
given(this.channel.send(any(Message.class))).willReturn(true);
@ -379,6 +380,7 @@ public class SimpAnnotationMethodMessageHandlerTests { @@ -379,6 +380,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
}
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void fluxNotHandled() {
Message emptyMessage = MessageBuilder.withPayload(new byte[0]).build();
given(this.channel.send(any(Message.class))).willReturn(true);

2
spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java

@ -81,7 +81,7 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests @@ -81,7 +81,7 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests
public void testEntityManagerProxyIsProxy() {
assertTrue(Proxy.isProxyClass(sharedEntityManager.getClass()));
Query q = sharedEntityManager.createQuery("select p from Person as p");
List<Person> people = q.getResultList();
q.getResultList();
assertTrue("Should be open to start with", sharedEntityManager.isOpen());
sharedEntityManager.close();

1
spring-orm/src/test/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryIntegrationTests.java

@ -33,7 +33,6 @@ import org.springframework.dao.DataAccessException; @@ -33,7 +33,6 @@ import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionException;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;

2
spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateNativeEntityManagerFactoryIntegrationTests.java

@ -71,7 +71,7 @@ public class HibernateNativeEntityManagerFactoryIntegrationTests extends Abstrac @@ -71,7 +71,7 @@ public class HibernateNativeEntityManagerFactoryIntegrationTests extends Abstrac
}
@Test
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testCurrentSession() {
String firstName = "Tony";
insertPerson(firstName);

4
spring-oxm/src/test/java/org/springframework/oxm/AbstractUnmarshallerTests.java

@ -37,7 +37,6 @@ import org.w3c.dom.Element; @@ -37,7 +37,6 @@ import org.w3c.dom.Element;
import org.w3c.dom.Text;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
import org.springframework.util.xml.StaxUtils;
@ -98,8 +97,9 @@ public abstract class AbstractUnmarshallerTests<U extends Unmarshaller> { @@ -98,8 +97,9 @@ public abstract class AbstractUnmarshallerTests<U extends Unmarshaller> {
}
@Test
@SuppressWarnings("deprecation")
public void unmarshalSAXSource() throws Exception {
XMLReader reader = XMLReaderFactory.createXMLReader();
XMLReader reader = org.xml.sax.helpers.XMLReaderFactory.createXMLReader();
SAXSource source = new SAXSource(reader, new InputSource(new StringReader(INPUT_STRING)));
Object flights = unmarshaller.unmarshal(source);
testFlights(flights);

5
spring-web/src/test/java/org/springframework/http/ResponseCookieTests.java

@ -13,13 +13,10 @@ @@ -13,13 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.http;
import java.time.Duration;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import org.junit.Test;

1
spring-web/src/test/java/org/springframework/http/converter/FormHttpMessageConverterTests.java

@ -30,7 +30,6 @@ import org.apache.commons.fileupload.FileItemFactory; @@ -30,7 +30,6 @@ import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.FileUpload;
import org.apache.commons.fileupload.RequestContext;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.hamcrest.CoreMatchers;
import org.hamcrest.Matchers;
import org.junit.Test;

1
spring-web/src/test/java/org/springframework/web/cors/reactive/UrlBasedCorsConfigurationSourceTests.java

@ -21,7 +21,6 @@ import org.junit.Test; @@ -21,7 +21,6 @@ import org.junit.Test;
import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
import org.springframework.mock.web.test.server.MockServerWebExchange;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.util.pattern.PathPatternParser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

4
spring-web/src/test/java/org/springframework/web/util/UriComponentsTests.java

@ -24,13 +24,9 @@ import java.net.URI; @@ -24,13 +24,9 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.springframework.web.util.UriComponents.UriTemplateVariables;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.not;

4
spring-webflux/src/main/java/org/springframework/web/reactive/DispatcherHandler.java

@ -21,8 +21,6 @@ import java.util.Collections; @@ -21,8 +21,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@ -74,8 +72,6 @@ public class DispatcherHandler implements WebHandler, ApplicationContextAware { @@ -74,8 +72,6 @@ public class DispatcherHandler implements WebHandler, ApplicationContextAware {
new ResponseStatusException(HttpStatus.NOT_FOUND, "No matching handler");
private static final Log logger = LogFactory.getLog(DispatcherHandler.class);
@Nullable
private List<HandlerMapping> handlerMappings;

1
spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyExtractorsTests.java

@ -65,7 +65,6 @@ import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; @@ -65,7 +65,6 @@ import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
import org.springframework.util.MultiValueMap;
import static org.junit.Assert.*;
import static org.mockito.Mockito.when;
import static org.springframework.http.codec.json.Jackson2CodecSupport.*;
/**

1
spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java

@ -30,7 +30,6 @@ import org.mockito.MockitoAnnotations; @@ -30,7 +30,6 @@ import org.mockito.MockitoAnnotations;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
import org.springframework.core.NamedInheritableThreadLocal;
import org.springframework.core.NamedThreadLocal;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;

1
spring-webflux/src/test/java/org/springframework/web/reactive/function/client/support/ClientResponseWrapperTests.java

@ -82,6 +82,7 @@ public class ClientResponseWrapperTests { @@ -82,6 +82,7 @@ public class ClientResponseWrapperTests {
}
@Test
@SuppressWarnings("unchecked")
public void cookies() {
MultiValueMap<String, ResponseCookie> cookies = mock(MultiValueMap.class);
when(mockResponse.cookies()).thenReturn(cookies);

1
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapperTests.java

@ -136,6 +136,7 @@ public class ServerRequestWrapperTests { @@ -136,6 +136,7 @@ public class ServerRequestWrapperTests {
}
@Test
@SuppressWarnings("unchecked")
public void cookies() {
MultiValueMap<String, HttpCookie> cookies = mock(MultiValueMap.class);
when(mockRequest.cookies()).thenReturn(cookies);

1
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ServerWebExchangeArgumentResolverTests.java

@ -20,7 +20,6 @@ import java.time.ZoneId; @@ -20,7 +20,6 @@ import java.time.ZoneId;
import java.util.Locale;
import java.util.TimeZone;
import org.junit.Before;
import org.junit.Test;
import reactor.core.publisher.Mono;

2
spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/view/script/ScriptTemplateWithBindingsExtensions.kt

@ -13,4 +13,4 @@ fun ScriptTemplateWithBindings.i18n(code: String) = @@ -13,4 +13,4 @@ fun ScriptTemplateWithBindings.i18n(code: String) =
var ScriptTemplateWithBindings.foo: String
get() = bindings["foo"] as String
set(value) { throw UnsupportedOperationException() }
set(@Suppress("UNUSED_PARAMETER") value) { throw UnsupportedOperationException() }

6
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandler.java

@ -23,9 +23,6 @@ import java.util.function.Consumer; @@ -23,9 +23,6 @@ import java.util.function.Consumer;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.MethodParameter;
import org.springframework.core.ReactiveAdapterRegistry;
import org.springframework.core.ResolvableType;
@ -60,9 +57,6 @@ import org.springframework.web.method.support.ModelAndViewContainer; @@ -60,9 +57,6 @@ import org.springframework.web.method.support.ModelAndViewContainer;
*/
public class ResponseBodyEmitterReturnValueHandler implements HandlerMethodReturnValueHandler {
private static final Log logger = LogFactory.getLog(ResponseBodyEmitterReturnValueHandler.class);
private final List<HttpMessageConverter<?>> messageConverters;
private final ReactiveTypeHandler reactiveHandler;

1
spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java

@ -85,6 +85,7 @@ public class XmlWebApplicationContextTests extends AbstractApplicationContextTes @@ -85,6 +85,7 @@ public class XmlWebApplicationContextTests extends AbstractApplicationContextTes
}
@Test
@SuppressWarnings("deprecation")
public void environmentMerge() {
assertThat(this.root.getEnvironment().acceptsProfiles("rootProfile1"), is(true));
assertThat(this.root.getEnvironment().acceptsProfiles("wacProfile1"), is(false));

20
spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java

@ -265,26 +265,6 @@ public class RequestMappingHandlerAdapterTests { @@ -265,26 +265,6 @@ public class RequestMappingHandlerAdapterTests {
assertEquals(handlerCount, this.handlerAdapter.getReturnValueHandlers().size());
}
private void testJsonp(String value, boolean validValue) throws Exception {
this.request = new MockHttpServletRequest("GET", "/");
this.request.addHeader("Accept", MediaType.APPLICATION_JSON_VALUE);
this.request.setParameter("c", value);
this.response = new MockHttpServletResponse();
HandlerMethod handlerMethod = handlerMethod(new SimpleController(), "handleWithResponseEntity");
this.handlerAdapter.afterPropertiesSet();
this.handlerAdapter.handle(this.request, this.response, handlerMethod);
assertEquals(200, this.response.getStatus());
if (validValue) {
assertEquals("/**/" + value + "({\"foo\":\"bar\"});", this.response.getContentAsString());
}
else {
assertEquals("{\"foo\":\"bar\"}", this.response.getContentAsString());
}
}
@SuppressWarnings("unused")
private static class SimpleController {

1
spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessorTests.java

@ -936,6 +936,7 @@ public class RequestResponseBodyMethodProcessorTests { @@ -936,6 +936,7 @@ public class RequestResponseBodyMethodProcessorTests {
@RequestMapping
@ResponseBody
@SuppressWarnings("unchecked")
public List<T> handleTypeInfoList() {
List<T> list = new ArrayList<>();
list.add((T) new Foo("foo"));

2
spring-webmvc/src/test/kotlin/org/springframework/web/servlet/view/script/ScriptTemplateWithBindingsExtensions.kt

@ -13,4 +13,4 @@ fun ScriptTemplateWithBindings.i18n(code: String) = @@ -13,4 +13,4 @@ fun ScriptTemplateWithBindings.i18n(code: String) =
var ScriptTemplateWithBindings.foo: String
get() = bindings["foo"] as String
set(value) { throw UnsupportedOperationException()}
set(@Suppress("UNUSED_PARAMETER") value) { throw UnsupportedOperationException()}

1
spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java

@ -679,6 +679,7 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser { @@ -679,6 +679,7 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser {
private final List<WebSocketHandlerDecoratorFactory> factories;
@SuppressWarnings("unused")
public DecoratingFactoryBean(WebSocketHandler handler, List<WebSocketHandlerDecoratorFactory> factories) {
this.handler = handler;
this.factories = factories;

1
spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/HttpReceivingTransportHandlerTests.java

@ -18,7 +18,6 @@ package org.springframework.web.socket.sockjs.transport.handler; @@ -18,7 +18,6 @@ package org.springframework.web.socket.sockjs.transport.handler;
import org.junit.Test;
import org.springframework.http.MediaType;
import org.springframework.web.socket.AbstractHttpRequestTests;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketHandler;

Loading…
Cancel
Save