Fixes for ignored tests after last week's nullability commit
Issue: SPR-15540
This commit is contained in:
parent
58242f2249
commit
7dd8dc62a5
|
@ -179,8 +179,8 @@ public class SendToMethodReturnValueHandler implements HandlerMethodReturnValueH
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (annotation instanceof SendTo) {
|
else {
|
||||||
SendTo sendTo = (SendTo) annotation;
|
SendTo sendTo = (SendTo) annotation; // possibly null
|
||||||
String[] destinations = getTargetDestinations(sendTo, message, this.defaultDestinationPrefix);
|
String[] destinations = getTargetDestinations(sendTo, message, this.defaultDestinationPrefix);
|
||||||
for (String destination : destinations) {
|
for (String destination : destinations) {
|
||||||
destination = this.placeholderHelper.replacePlaceholders(destination, varResolver);
|
destination = this.placeholderHelper.replacePlaceholders(destination, varResolver);
|
||||||
|
|
|
@ -27,7 +27,6 @@ import javax.security.auth.Subject;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonView;
|
import com.fasterxml.jackson.annotation.JsonView;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Captor;
|
import org.mockito.Captor;
|
||||||
|
@ -176,7 +175,6 @@ public class SendToMethodReturnValueHandlerTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore // TODO: NULLABLE
|
|
||||||
public void sendToNoAnnotations() throws Exception {
|
public void sendToNoAnnotations() throws Exception {
|
||||||
given(this.messageChannel.send(any(Message.class))).willReturn(true);
|
given(this.messageChannel.send(any(Message.class))).willReturn(true);
|
||||||
|
|
||||||
|
@ -346,7 +344,6 @@ public class SendToMethodReturnValueHandlerTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore // TODO: NULLABLE
|
|
||||||
public void testHeadersToSend() throws Exception {
|
public void testHeadersToSend() throws Exception {
|
||||||
Message<?> message = createMessage("sess1", "sub1", "/app", "/dest", null);
|
Message<?> message = createMessage("sess1", "sub1", "/app", "/dest", null);
|
||||||
|
|
||||||
|
@ -530,7 +527,6 @@ public class SendToMethodReturnValueHandlerTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore // TODO: NULLABLE
|
|
||||||
public void jsonView() throws Exception {
|
public void jsonView() throws Exception {
|
||||||
given(this.messageChannel.send(any(Message.class))).willReturn(true);
|
given(this.messageChannel.send(any(Message.class))).willReturn(true);
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Captor;
|
import org.mockito.Captor;
|
||||||
|
@ -238,7 +237,6 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore // TODO: NULLABLE
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void listenableFutureSuccess() {
|
public void listenableFutureSuccess() {
|
||||||
Message emptyMessage = (Message) MessageBuilder.withPayload(new byte[0]).build();
|
Message emptyMessage = (Message) MessageBuilder.withPayload(new byte[0]).build();
|
||||||
|
@ -277,7 +275,6 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore // TODO: NULLABLE
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void completableFutureSuccess() {
|
public void completableFutureSuccess() {
|
||||||
Message emptyMessage = (Message) MessageBuilder.withPayload(new byte[0]).build();
|
Message emptyMessage = (Message) MessageBuilder.withPayload(new byte[0]).build();
|
||||||
|
|
|
@ -19,7 +19,6 @@ package org.springframework.messaging.simp.user;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
@ -123,7 +122,6 @@ public class UserDestinationMessageHandlerTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore // TODO: NULLABLE
|
|
||||||
public void handleMessageFromBrokerWithActiveSession() {
|
public void handleMessageFromBrokerWithActiveSession() {
|
||||||
TestSimpUser simpUser = new TestSimpUser("joe");
|
TestSimpUser simpUser = new TestSimpUser("joe");
|
||||||
simpUser.addSessions(new TestSimpSession("123"));
|
simpUser.addSessions(new TestSimpSession("123"));
|
||||||
|
|
|
@ -200,11 +200,11 @@ public abstract class AbstractMessageConverterMethodArgumentResolver implements
|
||||||
logger.debug("Read [" + targetType + "] as \"" + contentType + "\" with [" + converter + "]");
|
logger.debug("Read [" + targetType + "] as \"" + contentType + "\" with [" + converter + "]");
|
||||||
}
|
}
|
||||||
if (message.hasBody()) {
|
if (message.hasBody()) {
|
||||||
HttpInputMessage inputMessageToUse =
|
HttpInputMessage msgToUse =
|
||||||
getAdvice().beforeBodyRead(message, parameter, targetType, converterType);
|
getAdvice().beforeBodyRead(message, parameter, targetType, converterType);
|
||||||
body = (genericConverter != null ? genericConverter.read(targetType, contextClass, message) :
|
body = (genericConverter != null ? genericConverter.read(targetType, contextClass, msgToUse) :
|
||||||
((HttpMessageConverter<T>) converter).read(targetClass, message));
|
((HttpMessageConverter<T>) converter).read(targetClass, msgToUse));
|
||||||
body = getAdvice().afterBodyRead(body, inputMessageToUse, parameter, targetType, converterType);
|
body = getAdvice().afterBodyRead(body, msgToUse, parameter, targetType, converterType);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
body = getAdvice().handleEmptyBody(null, message, parameter, targetType, converterType);
|
body = getAdvice().handleEmptyBody(null, message, parameter, targetType, converterType);
|
||||||
|
|
|
@ -117,6 +117,7 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
|
||||||
@Nullable ContentNegotiationManager manager, @Nullable List<Object> requestResponseBodyAdvice) {
|
@Nullable ContentNegotiationManager manager, @Nullable List<Object> requestResponseBodyAdvice) {
|
||||||
|
|
||||||
super(converters, requestResponseBodyAdvice);
|
super(converters, requestResponseBodyAdvice);
|
||||||
|
|
||||||
this.contentNegotiationManager = (manager != null ? manager : new ContentNegotiationManager());
|
this.contentNegotiationManager = (manager != null ? manager : new ContentNegotiationManager());
|
||||||
this.pathStrategy = initPathStrategy(this.contentNegotiationManager);
|
this.pathStrategy = initPathStrategy(this.contentNegotiationManager);
|
||||||
this.safeExtensions.addAll(this.contentNegotiationManager.getAllFileExtensions());
|
this.safeExtensions.addAll(this.contentNegotiationManager.getAllFileExtensions());
|
||||||
|
@ -163,7 +164,7 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
|
||||||
* @throws HttpMediaTypeNotAcceptableException thrown when the conditions indicated
|
* @throws HttpMediaTypeNotAcceptableException thrown when the conditions indicated
|
||||||
* by the {@code Accept} header on the request cannot be met by the message converters
|
* by the {@code Accept} header on the request cannot be met by the message converters
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
protected <T> void writeWithMessageConverters(@Nullable T value, MethodParameter returnType,
|
protected <T> void writeWithMessageConverters(@Nullable T value, MethodParameter returnType,
|
||||||
ServletServerHttpRequest inputMessage, ServletServerHttpResponse outputMessage)
|
ServletServerHttpRequest inputMessage, ServletServerHttpResponse outputMessage)
|
||||||
throws IOException, HttpMediaTypeNotAcceptableException, HttpMessageNotWritableException {
|
throws IOException, HttpMediaTypeNotAcceptableException, HttpMessageNotWritableException {
|
||||||
|
@ -223,35 +224,26 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
|
||||||
|
|
||||||
if (selectedMediaType != null) {
|
if (selectedMediaType != null) {
|
||||||
selectedMediaType = selectedMediaType.removeQualityValue();
|
selectedMediaType = selectedMediaType.removeQualityValue();
|
||||||
for (HttpMessageConverter<?> messageConverter : this.messageConverters) {
|
for (HttpMessageConverter<?> converter : this.messageConverters) {
|
||||||
if (messageConverter instanceof GenericHttpMessageConverter) {
|
GenericHttpMessageConverter genericConverter =
|
||||||
if (((GenericHttpMessageConverter) messageConverter).canWrite(
|
(converter instanceof GenericHttpMessageConverter ? (GenericHttpMessageConverter<?>) converter : null);
|
||||||
declaredType, valueType, selectedMediaType)) {
|
if (genericConverter != null ?
|
||||||
|
((GenericHttpMessageConverter) converter).canWrite(declaredType, valueType, selectedMediaType) :
|
||||||
|
converter.canWrite(valueType, selectedMediaType)) {
|
||||||
outputValue = (T) getAdvice().beforeBodyWrite(outputValue, returnType, selectedMediaType,
|
outputValue = (T) getAdvice().beforeBodyWrite(outputValue, returnType, selectedMediaType,
|
||||||
(Class<? extends HttpMessageConverter<?>>) messageConverter.getClass(),
|
(Class<? extends HttpMessageConverter<?>>) converter.getClass(),
|
||||||
inputMessage, outputMessage);
|
inputMessage, outputMessage);
|
||||||
if (outputValue != null) {
|
if (outputValue != null) {
|
||||||
addContentDispositionHeader(inputMessage, outputMessage);
|
addContentDispositionHeader(inputMessage, outputMessage);
|
||||||
((GenericHttpMessageConverter) messageConverter).write(
|
if (genericConverter != null) {
|
||||||
outputValue, declaredType, selectedMediaType, outputMessage);
|
genericConverter.write(outputValue, declaredType, selectedMediaType, outputMessage);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
((HttpMessageConverter) converter).write(outputValue, selectedMediaType, outputMessage);
|
||||||
|
}
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Written [" + outputValue + "] as \"" + selectedMediaType +
|
logger.debug("Written [" + outputValue + "] as \"" + selectedMediaType +
|
||||||
"\" using [" + messageConverter + "]");
|
"\" using [" + converter + "]");
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (messageConverter.canWrite(valueType, selectedMediaType)) {
|
|
||||||
outputValue = (T) getAdvice().beforeBodyWrite(outputValue, returnType, selectedMediaType,
|
|
||||||
(Class<? extends HttpMessageConverter<?>>) messageConverter.getClass(),
|
|
||||||
inputMessage, outputMessage);
|
|
||||||
if (outputValue != null) {
|
|
||||||
addContentDispositionHeader(inputMessage, outputMessage);
|
|
||||||
((HttpMessageConverter) messageConverter).write(outputValue, selectedMediaType, outputMessage);
|
|
||||||
if (logger.isDebugEnabled()) {
|
|
||||||
logger.debug("Written [" + outputValue + "] as \"" + selectedMediaType +
|
|
||||||
"\" using [" + messageConverter + "]");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -305,7 +297,9 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected List<MediaType> getProducibleMediaTypes(HttpServletRequest request, Class<?> valueClass, @Nullable Type declaredType) {
|
protected List<MediaType> getProducibleMediaTypes(HttpServletRequest request, Class<?> valueClass,
|
||||||
|
@Nullable Type declaredType) {
|
||||||
|
|
||||||
Set<MediaType> mediaTypes = (Set<MediaType>) request.getAttribute(HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE);
|
Set<MediaType> mediaTypes = (Set<MediaType>) request.getAttribute(HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE);
|
||||||
if (!CollectionUtils.isEmpty(mediaTypes)) {
|
if (!CollectionUtils.isEmpty(mediaTypes)) {
|
||||||
return new ArrayList<>(mediaTypes);
|
return new ArrayList<>(mediaTypes);
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class RequestResponseBodyMethodProcessor extends AbstractMessageConverter
|
||||||
* @since 4.2
|
* @since 4.2
|
||||||
*/
|
*/
|
||||||
public RequestResponseBodyMethodProcessor(List<HttpMessageConverter<?>> converters,
|
public RequestResponseBodyMethodProcessor(List<HttpMessageConverter<?>> converters,
|
||||||
List<Object> requestResponseBodyAdvice) {
|
@Nullable List<Object> requestResponseBodyAdvice) {
|
||||||
|
|
||||||
super(converters, null, requestResponseBodyAdvice);
|
super(converters, null, requestResponseBodyAdvice);
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ public class RequestResponseBodyMethodProcessor extends AbstractMessageConverter
|
||||||
* {@code @ResponseBody}.
|
* {@code @ResponseBody}.
|
||||||
*/
|
*/
|
||||||
public RequestResponseBodyMethodProcessor(List<HttpMessageConverter<?>> converters,
|
public RequestResponseBodyMethodProcessor(List<HttpMessageConverter<?>> converters,
|
||||||
ContentNegotiationManager manager, List<Object> requestResponseBodyAdvice) {
|
@Nullable ContentNegotiationManager manager, @Nullable List<Object> requestResponseBodyAdvice) {
|
||||||
|
|
||||||
super(converters, manager, requestResponseBodyAdvice);
|
super(converters, manager, requestResponseBodyAdvice);
|
||||||
}
|
}
|
||||||
|
|
|
@ -507,7 +507,6 @@ public class RequestResponseBodyMethodProcessorTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // SPR-12501
|
@Test // SPR-12501
|
||||||
@Ignore // TODO: NULLABLE
|
|
||||||
public void resolveArgumentWithJacksonJsonView() throws Exception {
|
public void resolveArgumentWithJacksonJsonView() throws Exception {
|
||||||
String content = "{\"withView1\" : \"with\", \"withView2\" : \"with\", \"withoutView\" : \"without\"}";
|
String content = "{\"withView1\" : \"with\", \"withView2\" : \"with\", \"withoutView\" : \"without\"}";
|
||||||
this.servletRequest.setContent(content.getBytes("UTF-8"));
|
this.servletRequest.setContent(content.getBytes("UTF-8"));
|
||||||
|
@ -534,7 +533,6 @@ public class RequestResponseBodyMethodProcessorTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // SPR-12501
|
@Test // SPR-12501
|
||||||
@Ignore // TODO: NULLABLE
|
|
||||||
public void resolveHttpEntityArgumentWithJacksonJsonView() throws Exception {
|
public void resolveHttpEntityArgumentWithJacksonJsonView() throws Exception {
|
||||||
String content = "{\"withView1\" : \"with\", \"withView2\" : \"with\", \"withoutView\" : \"without\"}";
|
String content = "{\"withView1\" : \"with\", \"withView2\" : \"with\", \"withoutView\" : \"without\"}";
|
||||||
this.servletRequest.setContent(content.getBytes("UTF-8"));
|
this.servletRequest.setContent(content.getBytes("UTF-8"));
|
||||||
|
@ -562,7 +560,6 @@ public class RequestResponseBodyMethodProcessorTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // SPR-12501
|
@Test // SPR-12501
|
||||||
@Ignore // TODO: NULLABLE
|
|
||||||
public void resolveArgumentWithJacksonJsonViewAndXmlMessageConverter() throws Exception {
|
public void resolveArgumentWithJacksonJsonViewAndXmlMessageConverter() throws Exception {
|
||||||
String content = "<root><withView1>with</withView1><withView2>with</withView2><withoutView>without</withoutView></root>";
|
String content = "<root><withView1>with</withView1><withView2>with</withView2><withoutView>without</withoutView></root>";
|
||||||
this.servletRequest.setContent(content.getBytes("UTF-8"));
|
this.servletRequest.setContent(content.getBytes("UTF-8"));
|
||||||
|
@ -589,7 +586,6 @@ public class RequestResponseBodyMethodProcessorTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // SPR-12501
|
@Test // SPR-12501
|
||||||
@Ignore // TODO: NULLABLE
|
|
||||||
public void resolveHttpEntityArgumentWithJacksonJsonViewAndXmlMessageConverter() throws Exception {
|
public void resolveHttpEntityArgumentWithJacksonJsonViewAndXmlMessageConverter() throws Exception {
|
||||||
String content = "<root><withView1>with</withView1><withView2>with</withView2><withoutView>without</withoutView></root>";
|
String content = "<root><withView1>with</withView1><withView2>with</withView2><withoutView>without</withoutView></root>";
|
||||||
this.servletRequest.setContent(content.getBytes("UTF-8"));
|
this.servletRequest.setContent(content.getBytes("UTF-8"));
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2015 the original author or authors.
|
* Copyright 2002-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -23,7 +23,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
import org.junit.runners.Parameterized;
|
||||||
|
@ -67,7 +66,6 @@ import static org.springframework.web.socket.messaging.StompTextMessageBuilder.*
|
||||||
* @author Rossen Stoyanchev
|
* @author Rossen Stoyanchev
|
||||||
*/
|
*/
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(Parameterized.class)
|
||||||
@Ignore // TODO: NULLABLE
|
|
||||||
public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegrationTests {
|
public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegrationTests {
|
||||||
|
|
||||||
private static final long TIMEOUT = 10;
|
private static final long TIMEOUT = 10;
|
||||||
|
@ -120,8 +118,7 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SPR-10930
|
@Test // SPR-10930
|
||||||
@Test
|
|
||||||
public void sendMessageToBrokerAndReceiveReplyViaTopic() throws Exception {
|
public void sendMessageToBrokerAndReceiveReplyViaTopic() throws Exception {
|
||||||
TextMessage m1 = create(StompCommand.SUBSCRIBE).headers("id:subs1", "destination:/topic/foo").build();
|
TextMessage m1 = create(StompCommand.SUBSCRIBE).headers("id:subs1", "destination:/topic/foo").build();
|
||||||
TextMessage m2 = create(StompCommand.SEND).headers("destination:/topic/foo").body("5").build();
|
TextMessage m2 = create(StompCommand.SEND).headers("destination:/topic/foo").body("5").build();
|
||||||
|
@ -140,8 +137,7 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SPR-11648
|
@Test // SPR-11648
|
||||||
@Test
|
|
||||||
public void sendSubscribeToControllerAndReceiveReply() throws Exception {
|
public void sendSubscribeToControllerAndReceiveReply() throws Exception {
|
||||||
String destHeader = "destination:/app/number";
|
String destHeader = "destination:/app/number";
|
||||||
TextMessage message = create(StompCommand.SUBSCRIBE).headers("id:subs1", destHeader).build();
|
TextMessage message = create(StompCommand.SUBSCRIBE).headers("id:subs1", destHeader).build();
|
||||||
|
|
Loading…
Reference in New Issue