Rossen Stoyanchev
2017-10-20 16:41:40 -04:00
parent 8ad212dae2
commit 1cc5afe24b
197 changed files with 1688 additions and 994 deletions

View File

@@ -236,7 +236,9 @@ public class MappingJackson2MessageConverter extends AbstractMessageConverter {
@Override
@Nullable
protected Object convertToInternal(Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) {
protected Object convertToInternal(Object payload, @Nullable MessageHeaders headers,
@Nullable Object conversionHint) {
try {
Class<?> view = getSerializationView(conversionHint);
if (byte[].class == getSerializedPayloadClass()) {

View File

@@ -166,7 +166,9 @@ public class MarshallingMessageConverter extends AbstractMessageConverter {
@Override
@Nullable
protected Object convertToInternal(Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) {
protected Object convertToInternal(Object payload, @Nullable MessageHeaders headers,
@Nullable Object conversionHint) {
Assert.notNull(this.marshaller, "Property 'marshaller' is required");
try {
if (byte[].class == getSerializedPayloadClass()) {

View File

@@ -122,12 +122,16 @@ public abstract class AbstractMessageSendingTemplate<D> implements MessageSendin
}
@Override
public void convertAndSend(D destination, Object payload, @Nullable Map<String, Object> headers) throws MessagingException {
public void convertAndSend(D destination, Object payload, @Nullable Map<String, Object> headers)
throws MessagingException {
convertAndSend(destination, payload, headers, null);
}
@Override
public void convertAndSend(Object payload, @Nullable MessagePostProcessor postProcessor) throws MessagingException {
public void convertAndSend(Object payload, @Nullable MessagePostProcessor postProcessor)
throws MessagingException {
convertAndSend(getRequiredDefaultDestination(), payload, postProcessor);
}

View File

@@ -104,7 +104,7 @@ public interface MessageSendingOperations<D> {
* @param headers headers for the message to send
* @param postProcessor the post processor to apply to the message
*/
void convertAndSend(D destination, Object payload, @Nullable Map<String, Object> headers, @Nullable MessagePostProcessor postProcessor)
throws MessagingException;
void convertAndSend(D destination, Object payload, @Nullable Map<String, Object> headers,
@Nullable MessagePostProcessor postProcessor) throws MessagingException;
}

View File

@@ -39,7 +39,8 @@ import org.springframework.util.StringUtils;
* @author Rossen Stoyanchev
* @since 4.0
*/
public class DestinationPatternsMessageCondition extends AbstractMessageCondition<DestinationPatternsMessageCondition> {
public class DestinationPatternsMessageCondition
extends AbstractMessageCondition<DestinationPatternsMessageCondition> {
public static final String LOOKUP_DESTINATION_HEADER = "lookupDestination";

View File

@@ -76,7 +76,9 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle
* and {@code #{...}} SpEL expressions in default values, or {@code null} if default
* values are not expected to contain expressions
*/
protected AbstractNamedValueMethodArgumentResolver(ConversionService cs, @Nullable ConfigurableBeanFactory beanFactory) {
protected AbstractNamedValueMethodArgumentResolver(ConversionService cs,
@Nullable ConfigurableBeanFactory beanFactory) {
this.conversionService = (cs != null ? cs : DefaultConversionService.getSharedInstance());
this.configurableBeanFactory = beanFactory;
this.expressionContext = (beanFactory != null ? new BeanExpressionContext(beanFactory, null) : null);

View File

@@ -55,7 +55,8 @@ import org.springframework.validation.Validator;
* @see #setValidator
* @see #setCustomArgumentResolvers
*/
public class DefaultMessageHandlerMethodFactory implements MessageHandlerMethodFactory, BeanFactoryAware, InitializingBean {
public class DefaultMessageHandlerMethodFactory
implements MessageHandlerMethodFactory, BeanFactoryAware, InitializingBean {
private ConversionService conversionService = new DefaultFormattingConversionService();

View File

@@ -68,7 +68,9 @@ public class HandlerMethodArgumentResolverComposite implements HandlerMethodArgu
/**
* Add the given {@link HandlerMethodArgumentResolver}s.
*/
public HandlerMethodArgumentResolverComposite addResolvers(@Nullable List<? extends HandlerMethodArgumentResolver> argumentResolvers) {
public HandlerMethodArgumentResolverComposite addResolvers(
@Nullable List<? extends HandlerMethodArgumentResolver> argumentResolvers) {
if (argumentResolvers != null) {
for (HandlerMethodArgumentResolver resolver : argumentResolvers) {
this.argumentResolvers.add(resolver);

View File

@@ -43,7 +43,8 @@ public class SimpAttributes {
public static final String SESSION_COMPLETED_NAME = SimpAttributes.class.getName() + ".COMPLETED";
/** Prefix for the name of session attributes used to store destruction callbacks. */
public static final String DESTRUCTION_CALLBACK_NAME_PREFIX = SimpAttributes.class.getName() + ".DESTRUCTION_CALLBACK.";
public static final String DESTRUCTION_CALLBACK_NAME_PREFIX =
SimpAttributes.class.getName() + ".DESTRUCTION_CALLBACK.";
private static final Log logger = LogFactory.getLog(SimpAttributes.class);

View File

@@ -88,7 +88,9 @@ public class SimpMessageHeaderAccessor extends NativeMessageHeaderAccessor {
* A constructor for creating new message headers.
* This constructor is protected. See factory methods in this and sub-classes.
*/
protected SimpMessageHeaderAccessor(SimpMessageType messageType, @Nullable Map<String, List<String>> externalSourceHeaders) {
protected SimpMessageHeaderAccessor(SimpMessageType messageType,
@Nullable Map<String, List<String>> externalSourceHeaders) {
super(externalSourceHeaders);
Assert.notNull(messageType, "MessageType must not be null");
setHeader(MESSAGE_TYPE_HEADER, messageType);

View File

@@ -231,7 +231,7 @@ public class SimpMessagingTemplate extends AbstractMessageSendingTemplate<String
/**
* Creates a new map and puts the given headers under the key
* {@link org.springframework.messaging.support.NativeMessageHeaderAccessor#NATIVE_HEADERS NATIVE_HEADERS NATIVE_HEADERS NATIVE_HEADERS}.
* {@link NativeMessageHeaderAccessor#NATIVE_HEADERS NATIVE_HEADERS NATIVE_HEADERS NATIVE_HEADERS}.
* effectively treats the input header map as headers to be sent out to the
* destination.
* <p>However if the given headers already contain the key

View File

@@ -433,7 +433,9 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry {
@Nullable
public Subscription getSubscription(String subscriptionId) {
for (Map.Entry<String, Set<DefaultSubscriptionRegistry.Subscription>> destinationEntry : this.destinationLookup.entrySet()) {
for (Map.Entry<String, Set<DefaultSubscriptionRegistry.Subscription>> destinationEntry :
this.destinationLookup.entrySet()) {
Set<Subscription> subs = destinationEntry.getValue();
if (subs != null) {
for (Subscription sub : subs) {

View File

@@ -106,7 +106,9 @@ public class StompDecoder {
* @return the decoded messages, or an empty list if none
* @throws StompConversionException raised in case of decoding issues
*/
public List<Message<byte[]>> decode(ByteBuffer byteBuffer, @Nullable MultiValueMap<String, String> partialMessageHeaders) {
public List<Message<byte[]>> decode(ByteBuffer byteBuffer,
@Nullable MultiValueMap<String, String> partialMessageHeaders) {
List<Message<byte[]>> messages = new ArrayList<>();
while (byteBuffer.hasRemaining()) {
Message<byte[]> message = decodeMessage(byteBuffer, partialMessageHeaders);

View File

@@ -179,7 +179,9 @@ public abstract class AbstractMessageChannel implements MessageChannel, Intercep
}
}
public void triggerAfterSendCompletion(Message<?> message, MessageChannel channel, boolean sent, @Nullable Exception ex) {
public void triggerAfterSendCompletion(Message<?> message, MessageChannel channel,
boolean sent, @Nullable Exception ex) {
for (int i = this.sendInterceptorIndex; i >= 0; i--) {
ChannelInterceptor interceptor = interceptors.get(i);
try {

View File

@@ -47,8 +47,10 @@ public class MappingJackson2MessageConverterTests {
@Test
public void defaultConstructor() {
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
assertThat(converter.getSupportedMimeTypes(), contains(new MimeType("application", "json", StandardCharsets.UTF_8)));
assertFalse(converter.getObjectMapper().getDeserializationConfig().isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
assertThat(converter.getSupportedMimeTypes(),
contains(new MimeType("application", "json", StandardCharsets.UTF_8)));
assertFalse(converter.getObjectMapper().getDeserializationConfig()
.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
}
@Test // SPR-12724
@@ -56,7 +58,8 @@ public class MappingJackson2MessageConverterTests {
MimeType mimetype = new MimeType("application", "xml", StandardCharsets.UTF_8);
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter(mimetype);
assertThat(converter.getSupportedMimeTypes(), contains(mimetype));
assertFalse(converter.getObjectMapper().getDeserializationConfig().isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
assertFalse(converter.getObjectMapper().getDeserializationConfig()
.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
}
@Test // SPR-12724
@@ -65,13 +68,20 @@ public class MappingJackson2MessageConverterTests {
MimeType xmlMimetype = new MimeType("application", "xml", StandardCharsets.UTF_8);
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter(jsonMimetype, xmlMimetype);
assertThat(converter.getSupportedMimeTypes(), contains(jsonMimetype, xmlMimetype));
assertFalse(converter.getObjectMapper().getDeserializationConfig().isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
assertFalse(converter.getObjectMapper().getDeserializationConfig()
.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
}
@Test
public void fromMessage() throws Exception {
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
String payload = "{\"bytes\":\"AQI=\",\"array\":[\"Foo\",\"Bar\"],\"number\":42,\"string\":\"Foo\",\"bool\":true,\"fraction\":42.0}";
String payload = "{" +
"\"bytes\":\"AQI=\"," +
"\"array\":[\"Foo\",\"Bar\"]," +
"\"number\":42," +
"\"string\":\"Foo\"," +
"\"bool\":true," +
"\"fraction\":42.0}";
Message<?> message = MessageBuilder.withPayload(payload.getBytes(StandardCharsets.UTF_8)).build();
MyBean actual = (MyBean) converter.fromMessage(message, MyBean.class);

View File

@@ -157,12 +157,16 @@ public class MessageConverterTests {
}
@Override
protected Object convertFromInternal(Message<?> message, Class<?> targetClass, @Nullable Object conversionHint) {
protected Object convertFromInternal(Message<?> message, Class<?> targetClass,
@Nullable Object conversionHint) {
return "success-from";
}
@Override
protected Object convertToInternal(Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) {
protected Object convertToInternal(Object payload, @Nullable MessageHeaders headers,
@Nullable Object conversionHint) {
return "success-to";
}
}

View File

@@ -32,25 +32,25 @@ public class CachingDestinationResolverTests {
@Test
public void cachedDestination() {
@SuppressWarnings("unchecked")
DestinationResolver<String> destinationResolver = mock(DestinationResolver.class);
CachingDestinationResolverProxy<String> cachingDestinationResolver = new CachingDestinationResolverProxy<>(destinationResolver);
DestinationResolver<String> resolver = mock(DestinationResolver.class);
CachingDestinationResolverProxy<String> resolverProxy = new CachingDestinationResolverProxy<>(resolver);
given(destinationResolver.resolveDestination("abcd")).willReturn("dcba");
given(destinationResolver.resolveDestination("1234")).willReturn("4321");
given(resolver.resolveDestination("abcd")).willReturn("dcba");
given(resolver.resolveDestination("1234")).willReturn("4321");
assertEquals("dcba", cachingDestinationResolver.resolveDestination("abcd"));
assertEquals("4321", cachingDestinationResolver.resolveDestination("1234"));
assertEquals("4321", cachingDestinationResolver.resolveDestination("1234"));
assertEquals("dcba", cachingDestinationResolver.resolveDestination("abcd"));
assertEquals("dcba", resolverProxy.resolveDestination("abcd"));
assertEquals("4321", resolverProxy.resolveDestination("1234"));
assertEquals("4321", resolverProxy.resolveDestination("1234"));
assertEquals("dcba", resolverProxy.resolveDestination("abcd"));
verify(destinationResolver, times(1)).resolveDestination("abcd");
verify(destinationResolver, times(1)).resolveDestination("1234");
verify(resolver, times(1)).resolveDestination("abcd");
verify(resolver, times(1)).resolveDestination("1234");
}
@Test(expected = IllegalArgumentException.class)
public void noTargetSet() {
CachingDestinationResolverProxy<String> cachingDestinationResolver = new CachingDestinationResolverProxy<>();
cachingDestinationResolver.afterPropertiesSet();
CachingDestinationResolverProxy<String> resolverProxy = new CachingDestinationResolverProxy<>();
resolverProxy.afterPropertiesSet();
}
@Test(expected = IllegalArgumentException.class)

View File

@@ -37,56 +37,53 @@ import static org.junit.Assert.*;
*/
public class AnnotationExceptionHandlerMethodResolverTests {
private final AnnotationExceptionHandlerMethodResolver resolver =
new AnnotationExceptionHandlerMethodResolver(ExceptionController.class);
@Test
public void resolveMethodFromAnnotation() {
AnnotationExceptionHandlerMethodResolver resolver = new AnnotationExceptionHandlerMethodResolver(ExceptionController.class);
IOException exception = new IOException();
assertEquals("handleIOException", resolver.resolveMethod(exception).getName());
assertEquals("handleIOException", this.resolver.resolveMethod(exception).getName());
}
@Test
public void resolveMethodFromArgument() {
AnnotationExceptionHandlerMethodResolver resolver = new AnnotationExceptionHandlerMethodResolver(ExceptionController.class);
IllegalArgumentException exception = new IllegalArgumentException();
assertEquals("handleIllegalArgumentException", resolver.resolveMethod(exception).getName());
assertEquals("handleIllegalArgumentException", this.resolver.resolveMethod(exception).getName());
}
@Test
public void resolveMethodFromArgumentWithErrorType() {
AnnotationExceptionHandlerMethodResolver resolver = new AnnotationExceptionHandlerMethodResolver(ExceptionController.class);
AssertionError exception = new AssertionError();
assertEquals("handleAssertionError", resolver.resolveMethod(new IllegalStateException(exception)).getName());
assertEquals("handleAssertionError", this.resolver.resolveMethod(new IllegalStateException(exception)).getName());
}
@Test
public void resolveMethodExceptionSubType() {
AnnotationExceptionHandlerMethodResolver resolver = new AnnotationExceptionHandlerMethodResolver(ExceptionController.class);
IOException ioException = new FileNotFoundException();
assertEquals("handleIOException", resolver.resolveMethod(ioException).getName());
assertEquals("handleIOException", this.resolver.resolveMethod(ioException).getName());
SocketException bindException = new BindException();
assertEquals("handleSocketException", resolver.resolveMethod(bindException).getName());
assertEquals("handleSocketException", this.resolver.resolveMethod(bindException).getName());
}
@Test
public void resolveMethodBestMatch() {
AnnotationExceptionHandlerMethodResolver resolver = new AnnotationExceptionHandlerMethodResolver(ExceptionController.class);
SocketException exception = new SocketException();
assertEquals("handleSocketException", resolver.resolveMethod(exception).getName());
assertEquals("handleSocketException", this.resolver.resolveMethod(exception).getName());
}
@Test
public void resolveMethodNoMatch() {
AnnotationExceptionHandlerMethodResolver resolver = new AnnotationExceptionHandlerMethodResolver(ExceptionController.class);
Exception exception = new Exception();
assertNull("1st lookup", resolver.resolveMethod(exception));
assertNull("2nd lookup from cache", resolver.resolveMethod(exception));
assertNull("1st lookup", this.resolver.resolveMethod(exception));
assertNull("2nd lookup from cache", this.resolver.resolveMethod(exception));
}
@Test
public void resolveMethodInherited() {
AnnotationExceptionHandlerMethodResolver resolver = new AnnotationExceptionHandlerMethodResolver(InheritedController.class);
IOException exception = new IOException();
assertEquals("handleIOException", resolver.resolveMethod(exception).getName());
assertEquals("handleIOException", this.resolver.resolveMethod(exception).getName());
}
@Test(expected = IllegalStateException.class)
@@ -101,6 +98,7 @@ public class AnnotationExceptionHandlerMethodResolverTests {
@Controller
@SuppressWarnings("unused")
static class ExceptionController {
public void handle() {}

View File

@@ -32,14 +32,17 @@ public class SimpMessageTypeMessageConditionTests {
@Test
public void combine() {
SimpMessageType actual = condition(SimpMessageType.MESSAGE).combine(condition(SimpMessageType.SUBSCRIBE)).getMessageType();
assertEquals(SimpMessageType.SUBSCRIBE, actual);
SimpMessageType messageType = SimpMessageType.MESSAGE;
SimpMessageType subscribeType = SimpMessageType.SUBSCRIBE;
actual = condition(SimpMessageType.MESSAGE).combine(condition(SimpMessageType.MESSAGE)).getMessageType();
assertEquals(SimpMessageType.MESSAGE, actual);
SimpMessageType actual = condition(messageType).combine(condition(subscribeType)).getMessageType();
assertEquals(subscribeType, actual);
actual = condition(SimpMessageType.SUBSCRIBE).combine(condition(SimpMessageType.SUBSCRIBE)).getMessageType();
assertEquals(SimpMessageType.SUBSCRIBE, actual);
actual = condition(messageType).combine(condition(messageType)).getMessageType();
assertEquals(messageType, actual);
actual = condition(subscribeType).combine(condition(subscribeType)).getMessageType();
assertEquals(subscribeType, actual);
}
@Test

View File

@@ -67,6 +67,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Controller;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.MimeTypeUtils;
import org.springframework.util.PathMatcher;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
import org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean;
@@ -132,7 +133,8 @@ public class MessageBrokerConfigurationTests {
@Test
public void clientOutboundChannelUsedByAnnotatedMethod() {
TestChannel channel = this.simpleBrokerContext.getBean("clientOutboundChannel", TestChannel.class);
SimpAnnotationMethodMessageHandler messageHandler = this.simpleBrokerContext.getBean(SimpAnnotationMethodMessageHandler.class);
SimpAnnotationMethodMessageHandler messageHandler =
this.simpleBrokerContext.getBean(SimpAnnotationMethodMessageHandler.class);
StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.SUBSCRIBE);
headers.setSessionId("sess1");
@@ -327,7 +329,8 @@ public class MessageBrokerConfigurationTests {
@Test
public void customArgumentAndReturnValueTypes() throws Exception {
SimpAnnotationMethodMessageHandler handler = this.customContext.getBean(SimpAnnotationMethodMessageHandler.class);
SimpAnnotationMethodMessageHandler handler =
this.customContext.getBean(SimpAnnotationMethodMessageHandler.class);
List<HandlerMethodArgumentResolver> customResolvers = handler.getCustomArgumentResolvers();
assertEquals(1, customResolvers.size());
@@ -385,8 +388,10 @@ public class MessageBrokerConfigurationTests {
DefaultSubscriptionRegistry registry = (DefaultSubscriptionRegistry) broker.getSubscriptionRegistry();
assertEquals("a.a", registry.getPathMatcher().combine("a", "a"));
SimpAnnotationMethodMessageHandler handler = this.customContext.getBean(SimpAnnotationMethodMessageHandler.class);
assertEquals("a.a", handler.getPathMatcher().combine("a", "a"));
PathMatcher pathMatcher =
this.customContext.getBean(SimpAnnotationMethodMessageHandler.class).getPathMatcher();
assertEquals("a.a", pathMatcher.combine("a", "a"));
DefaultUserDestinationResolver resolver = this.customContext.getBean(DefaultUserDestinationResolver.class);
assertNotNull(resolver);
@@ -536,7 +541,8 @@ public class MessageBrokerConfigurationTests {
@Override
protected void configureMessageBroker(MessageBrokerRegistry registry) {
registry.configureBrokerChannel().interceptors(this.interceptor, this.interceptor, this.interceptor);
registry.configureBrokerChannel().taskExecutor().corePoolSize(31).maxPoolSize(32).keepAliveSeconds(33).queueCapacity(34);
registry.configureBrokerChannel().taskExecutor()
.corePoolSize(31).maxPoolSize(32).keepAliveSeconds(33).queueCapacity(34);
registry.setPathMatcher(new AntPathMatcher(".")).enableSimpleBroker("/topic", "/queue");
registry.setCacheLimit(8192);
}

View File

@@ -217,7 +217,8 @@ public class DefaultStompSessionTests {
StompHeaders stompHeaders = StompHeaders.readOnlyStompHeaders(accessor.getNativeHeaders());
when(this.sessionHandler.getPayloadType(stompHeaders)).thenReturn(String.class);
this.session.handleMessage(MessageBuilder.createMessage(payload.getBytes(StandardCharsets.UTF_8), accessor.getMessageHeaders()));
this.session.handleMessage(MessageBuilder.createMessage(
payload.getBytes(StandardCharsets.UTF_8), accessor.getMessageHeaders()));
verify(this.sessionHandler).getPayloadType(stompHeaders);
verify(this.sessionHandler).handleFrame(stompHeaders, payload);

View File

@@ -49,7 +49,9 @@ import org.springframework.messaging.support.MessageBuilder;
import org.springframework.util.Assert;
import org.springframework.util.SocketUtils;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* Integration tests for {@link StompBrokerRelayMessageHandler} running against ActiveMQ.
@@ -509,7 +511,9 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {
@Override
protected boolean matchInternal(StompHeaderAccessor headers, Object payload) {
if (!this.subscriptionId.equals(headers.getSubscriptionId()) || !this.destination.equals(headers.getDestination())) {
if (!this.subscriptionId.equals(headers.getSubscriptionId()) ||
!this.destination.equals(headers.getDestination())) {
return false;
}
if (payload instanceof byte[] && this.payload instanceof byte[]) {

View File

@@ -31,8 +31,15 @@ import org.springframework.messaging.MessageHeaders;
import org.springframework.util.MimeTypeUtils;
import org.springframework.util.SerializationTestUtils;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.startsWith;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
* Test fixture for {@link MessageHeaderAccessor}.
@@ -314,9 +321,10 @@ public class MessageHeaderAccessorTests {
MessageHeaderAccessor accessor = new MessageHeaderAccessor();
accessor.setContentType(MimeTypeUtils.TEXT_PLAIN);
assertEquals("headers={contentType=text/plain} payload=p", accessor.getShortLogMessage("p"));
assertEquals("headers={contentType=text/plain} payload=p", accessor.getShortLogMessage("p".getBytes(StandardCharsets.UTF_8)));
assertEquals("headers={contentType=text/plain} payload=p", accessor.getShortLogMessage(new Object() {
String expected = "headers={contentType=text/plain} payload=p";
assertEquals(expected, accessor.getShortLogMessage("p"));
assertEquals(expected, accessor.getShortLogMessage("p".getBytes(StandardCharsets.UTF_8)));
assertEquals(expected, accessor.getShortLogMessage(new Object() {
@Override
public String toString() {
return "p";
@@ -349,9 +357,10 @@ public class MessageHeaderAccessorTests {
MessageHeaderAccessor accessor = new MessageHeaderAccessor();
accessor.setContentType(MimeTypeUtils.TEXT_PLAIN);
assertEquals("headers={contentType=text/plain} payload=p", accessor.getDetailedLogMessage("p"));
assertEquals("headers={contentType=text/plain} payload=p", accessor.getDetailedLogMessage("p".getBytes(StandardCharsets.UTF_8)));
assertEquals("headers={contentType=text/plain} payload=p", accessor.getDetailedLogMessage(new Object() {
String expected = "headers={contentType=text/plain} payload=p";
assertEquals(expected, accessor.getDetailedLogMessage("p"));
assertEquals(expected, accessor.getDetailedLogMessage("p".getBytes(StandardCharsets.UTF_8)));
assertEquals(expected, accessor.getDetailedLogMessage(new Object() {
@Override
public String toString() {
return "p";