Fix lines over 120 characters
https://github.com/spring-projects/spring-framework/wiki/Spring-Framework-Code-Style#line-wrapping
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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() {}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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[]) {
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user