Polish
This commit is contained in:
parent
9912a52bb8
commit
01c62f86b3
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -36,16 +36,16 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
|||
* @author Gary Russell
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class MessageHeadersTests {
|
||||
class MessageHeadersTests {
|
||||
|
||||
@Test
|
||||
public void testTimestamp() {
|
||||
void testTimestamp() {
|
||||
MessageHeaders headers = new MessageHeaders(null);
|
||||
assertThat(headers.getTimestamp()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTimestampOverwritten() throws Exception {
|
||||
void testTimestampOverwritten() throws Exception {
|
||||
MessageHeaders headers1 = new MessageHeaders(null);
|
||||
Thread.sleep(50L);
|
||||
MessageHeaders headers2 = new MessageHeaders(headers1);
|
||||
|
@ -53,59 +53,59 @@ public class MessageHeadersTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testTimestampProvided() throws Exception {
|
||||
void testTimestampProvided() {
|
||||
MessageHeaders headers = new MessageHeaders(null, null, 10L);
|
||||
assertThat(headers.getTimestamp()).isEqualTo(10L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTimestampProvidedNullValue() throws Exception {
|
||||
Map<String, Object> input = Collections.<String, Object>singletonMap(MessageHeaders.TIMESTAMP, 1L);
|
||||
void testTimestampProvidedNullValue() {
|
||||
Map<String, Object> input = Collections.singletonMap(MessageHeaders.TIMESTAMP, 1L);
|
||||
MessageHeaders headers = new MessageHeaders(input, null, null);
|
||||
assertThat(headers.getTimestamp()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTimestampNone() throws Exception {
|
||||
void testTimestampNone() {
|
||||
MessageHeaders headers = new MessageHeaders(null, null, -1L);
|
||||
assertThat(headers.getTimestamp()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIdOverwritten() throws Exception {
|
||||
void testIdOverwritten() {
|
||||
MessageHeaders headers1 = new MessageHeaders(null);
|
||||
MessageHeaders headers2 = new MessageHeaders(headers1);
|
||||
assertThat(headers2.getId()).isNotSameAs(headers1.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testId() {
|
||||
void testId() {
|
||||
MessageHeaders headers = new MessageHeaders(null);
|
||||
assertThat(headers.getId()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIdProvided() {
|
||||
void testIdProvided() {
|
||||
UUID id = new UUID(0L, 25L);
|
||||
MessageHeaders headers = new MessageHeaders(null, id, null);
|
||||
assertThat(headers.getId()).isEqualTo(id);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIdProvidedNullValue() {
|
||||
Map<String, Object> input = Collections.<String, Object>singletonMap(MessageHeaders.ID, new UUID(0L, 25L));
|
||||
void testIdProvidedNullValue() {
|
||||
Map<String, Object> input = Collections.singletonMap(MessageHeaders.ID, new UUID(0L, 25L));
|
||||
MessageHeaders headers = new MessageHeaders(input, null, null);
|
||||
assertThat(headers.getId()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIdNone() {
|
||||
void testIdNone() {
|
||||
MessageHeaders headers = new MessageHeaders(null, MessageHeaders.ID_VALUE_NONE, null);
|
||||
assertThat(headers.getId()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonTypedAccessOfHeaderValue() {
|
||||
void testNonTypedAccessOfHeaderValue() {
|
||||
Integer value = 123;
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("test", value);
|
||||
|
@ -114,7 +114,7 @@ public class MessageHeadersTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testTypedAccessOfHeaderValue() {
|
||||
void testTypedAccessOfHeaderValue() {
|
||||
Integer value = 123;
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("test", value);
|
||||
|
@ -123,7 +123,7 @@ public class MessageHeadersTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testHeaderValueAccessWithIncorrectType() {
|
||||
void testHeaderValueAccessWithIncorrectType() {
|
||||
Integer value = 123;
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("test", value);
|
||||
|
@ -133,21 +133,21 @@ public class MessageHeadersTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testNullHeaderValue() {
|
||||
void testNullHeaderValue() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
MessageHeaders headers = new MessageHeaders(map);
|
||||
assertThat(headers.get("nosuchattribute")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullHeaderValueWithTypedAccess() {
|
||||
void testNullHeaderValueWithTypedAccess() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
MessageHeaders headers = new MessageHeaders(map);
|
||||
assertThat(headers.get("nosuchattribute", String.class)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeaderKeys() {
|
||||
void testHeaderKeys() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("key1", "val1");
|
||||
map.put("key2", 123);
|
||||
|
@ -156,7 +156,7 @@ public class MessageHeadersTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void serializeWithAllSerializableHeaders() throws Exception {
|
||||
void serializeWithAllSerializableHeaders() throws Exception {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("name", "joe");
|
||||
map.put("age", 42);
|
||||
|
@ -169,7 +169,7 @@ public class MessageHeadersTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void serializeWithNonSerializableHeader() throws Exception {
|
||||
void serializeWithNonSerializableHeader() throws Exception {
|
||||
Object address = new Object();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("name", "joe");
|
||||
|
@ -183,7 +183,7 @@ public class MessageHeadersTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void subclassWithCustomIdAndNoTimestamp() {
|
||||
void subclassWithCustomIdAndNoTimestamp() {
|
||||
final AtomicLong id = new AtomicLong();
|
||||
@SuppressWarnings("serial")
|
||||
class MyMH extends MessageHeaders {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -35,43 +35,43 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class DefaultContentTypeResolverTests {
|
||||
class DefaultContentTypeResolverTests {
|
||||
|
||||
private final DefaultContentTypeResolver resolver = new DefaultContentTypeResolver();
|
||||
|
||||
|
||||
@Test
|
||||
public void resolve() {
|
||||
void resolve() {
|
||||
MessageHeaders headers = headers(MimeTypeUtils.APPLICATION_JSON);
|
||||
assertThat(this.resolver.resolve(headers)).isEqualTo(MimeTypeUtils.APPLICATION_JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveStringContentType() {
|
||||
void resolveStringContentType() {
|
||||
MessageHeaders headers = headers(MimeTypeUtils.APPLICATION_JSON_VALUE);
|
||||
assertThat(this.resolver.resolve(headers)).isEqualTo(MimeTypeUtils.APPLICATION_JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveInvalidStringContentType() {
|
||||
void resolveInvalidStringContentType() {
|
||||
MessageHeaders headers = headers("invalidContentType");
|
||||
assertThatExceptionOfType(InvalidMimeTypeException.class).isThrownBy(() -> this.resolver.resolve(headers));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveUnknownHeaderType() {
|
||||
void resolveUnknownHeaderType() {
|
||||
MessageHeaders headers = headers(1);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.resolver.resolve(headers));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveNoContentTypeHeader() {
|
||||
void resolveNoContentTypeHeader() {
|
||||
MessageHeaders headers = new MessageHeaders(Collections.emptyMap());
|
||||
assertThat(this.resolver.resolve(headers)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveDefaultMimeType() {
|
||||
void resolveDefaultMimeType() {
|
||||
this.resolver.setDefaultMimeType(MimeTypeUtils.APPLICATION_JSON);
|
||||
MessageHeaders headers = new MessageHeaders(Collections.emptyMap());
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class DefaultContentTypeResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveDefaultMimeTypeWithNoHeader() {
|
||||
void resolveDefaultMimeTypeWithNoHeader() {
|
||||
this.resolver.setDefaultMimeType(MimeTypeUtils.APPLICATION_JSON);
|
||||
assertThat(this.resolver.resolve(null)).isEqualTo(MimeTypeUtils.APPLICATION_JSON);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -33,25 +33,25 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
|||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class GenericMessageConverterTests {
|
||||
class GenericMessageConverterTests {
|
||||
|
||||
private final ConversionService conversionService = new DefaultConversionService();
|
||||
private final GenericMessageConverter converter = new GenericMessageConverter(conversionService);
|
||||
|
||||
@Test
|
||||
public void fromMessageWithConversion() {
|
||||
void fromMessageWithConversion() {
|
||||
Message<String> content = MessageBuilder.withPayload("33").build();
|
||||
assertThat(converter.fromMessage(content, Integer.class)).isEqualTo(33);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromMessageNoConverter() {
|
||||
void fromMessageNoConverter() {
|
||||
Message<Integer> content = MessageBuilder.withPayload(1234).build();
|
||||
assertThat(converter.fromMessage(content, Locale.class)).as("No converter from integer to locale").isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromMessageWithFailedConversion() {
|
||||
void fromMessageWithFailedConversion() {
|
||||
Message<String> content = MessageBuilder.withPayload("test not a number").build();
|
||||
assertThatExceptionOfType(MessageConversionException.class).isThrownBy(() ->
|
||||
converter.fromMessage(content, Integer.class))
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -41,16 +41,16 @@ import static org.assertj.core.api.Assertions.within;
|
|||
* @author Rossen Stoyanchev
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class GsonMessageConverterTests {
|
||||
class GsonMessageConverterTests {
|
||||
|
||||
@Test
|
||||
public void defaultConstructor() {
|
||||
void defaultConstructor() {
|
||||
GsonMessageConverter converter = new GsonMessageConverter();
|
||||
assertThat(converter.getSupportedMimeTypes()).contains(new MimeType("application", "json"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromMessage() {
|
||||
void fromMessage() {
|
||||
GsonMessageConverter converter = new GsonMessageConverter();
|
||||
String payload = "{\"array\":[\"Foo\",\"Bar\"]," +
|
||||
"\"number\":42,\"string\":\"Foo\",\"bool\":true,\"fraction\":42.0}";
|
||||
|
@ -65,7 +65,7 @@ public class GsonMessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fromMessageUntyped() {
|
||||
void fromMessageUntyped() {
|
||||
GsonMessageConverter converter = new GsonMessageConverter();
|
||||
String payload = "{\"array\":[\"Foo\",\"Bar\"]," +
|
||||
"\"number\":42,\"string\":\"Foo\",\"bool\":true,\"fraction\":42.0}";
|
||||
|
@ -81,7 +81,7 @@ public class GsonMessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fromMessageMatchingInstance() {
|
||||
void fromMessageMatchingInstance() {
|
||||
MyBean myBean = new MyBean();
|
||||
GsonMessageConverter converter = new GsonMessageConverter();
|
||||
Message<?> message = MessageBuilder.withPayload(myBean).build();
|
||||
|
@ -89,7 +89,7 @@ public class GsonMessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fromMessageInvalidJson() {
|
||||
void fromMessageInvalidJson() {
|
||||
GsonMessageConverter converter = new GsonMessageConverter();
|
||||
String payload = "FooBar";
|
||||
Message<?> message = MessageBuilder.withPayload(payload.getBytes(StandardCharsets.UTF_8)).build();
|
||||
|
@ -98,7 +98,7 @@ public class GsonMessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fromMessageValidJsonWithUnknownProperty() {
|
||||
void fromMessageValidJsonWithUnknownProperty() {
|
||||
GsonMessageConverter converter = new GsonMessageConverter();
|
||||
String payload = "{\"string\":\"string\",\"unknownProperty\":\"value\"}";
|
||||
Message<?> message = MessageBuilder.withPayload(payload.getBytes(StandardCharsets.UTF_8)).build();
|
||||
|
@ -107,7 +107,7 @@ public class GsonMessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fromMessageToList() throws Exception {
|
||||
void fromMessageToList() throws Exception {
|
||||
GsonMessageConverter converter = new GsonMessageConverter();
|
||||
String payload = "[1, 2, 3, 4, 5, 6, 7, 8, 9]";
|
||||
Message<?> message = MessageBuilder.withPayload(payload.getBytes(StandardCharsets.UTF_8)).build();
|
||||
|
@ -121,7 +121,7 @@ public class GsonMessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fromMessageToMessageWithPojo() throws Exception {
|
||||
void fromMessageToMessageWithPojo() throws Exception {
|
||||
GsonMessageConverter converter = new GsonMessageConverter();
|
||||
String payload = "{\"string\":\"foo\"}";
|
||||
Message<?> message = MessageBuilder.withPayload(payload.getBytes(StandardCharsets.UTF_8)).build();
|
||||
|
@ -135,7 +135,7 @@ public class GsonMessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void toMessage() {
|
||||
void toMessage() {
|
||||
GsonMessageConverter converter = new GsonMessageConverter();
|
||||
MyBean payload = new MyBean();
|
||||
payload.setString("Foo");
|
||||
|
@ -156,7 +156,7 @@ public class GsonMessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void toMessageUtf16() {
|
||||
void toMessageUtf16() {
|
||||
GsonMessageConverter converter = new GsonMessageConverter();
|
||||
MimeType contentType = new MimeType("application", "json", StandardCharsets.UTF_16BE);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
@ -170,7 +170,7 @@ public class GsonMessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void toMessageUtf16String() {
|
||||
void toMessageUtf16String() {
|
||||
GsonMessageConverter converter = new GsonMessageConverter();
|
||||
converter.setSerializedPayloadClass(String.class);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -42,16 +42,16 @@ import static org.assertj.core.api.Assertions.within;
|
|||
* @author Rossen Stoyanchev
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class JsonbMessageConverterTests {
|
||||
class JsonbMessageConverterTests {
|
||||
|
||||
@Test
|
||||
public void defaultConstructor() {
|
||||
void defaultConstructor() {
|
||||
JsonbMessageConverter converter = new JsonbMessageConverter();
|
||||
assertThat(converter.getSupportedMimeTypes()).contains(new MimeType("application", "json"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromMessage() {
|
||||
void fromMessage() {
|
||||
JsonbMessageConverter converter = new JsonbMessageConverter();
|
||||
String payload = "{\"array\":[\"Foo\",\"Bar\"]," +
|
||||
"\"number\":42,\"string\":\"Foo\",\"bool\":true,\"fraction\":42.0}";
|
||||
|
@ -66,7 +66,7 @@ public class JsonbMessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fromMessageUntyped() {
|
||||
void fromMessageUntyped() {
|
||||
JsonbMessageConverter converter = new JsonbMessageConverter();
|
||||
String payload = "{\"array\":[\"Foo\",\"Bar\"]," +
|
||||
"\"number\":42,\"string\":\"Foo\",\"bool\":true,\"fraction\":42.0}";
|
||||
|
@ -82,7 +82,7 @@ public class JsonbMessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fromMessageMatchingInstance() {
|
||||
void fromMessageMatchingInstance() {
|
||||
MyBean myBean = new MyBean();
|
||||
JsonbMessageConverter converter = new JsonbMessageConverter();
|
||||
Message<?> message = MessageBuilder.withPayload(myBean).build();
|
||||
|
@ -90,7 +90,7 @@ public class JsonbMessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fromMessageInvalidJson() {
|
||||
void fromMessageInvalidJson() {
|
||||
JsonbMessageConverter converter = new JsonbMessageConverter();
|
||||
String payload = "FooBar";
|
||||
Message<?> message = MessageBuilder.withPayload(payload.getBytes(StandardCharsets.UTF_8)).build();
|
||||
|
@ -99,7 +99,7 @@ public class JsonbMessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fromMessageValidJsonWithUnknownProperty() {
|
||||
void fromMessageValidJsonWithUnknownProperty() {
|
||||
JsonbMessageConverter converter = new JsonbMessageConverter();
|
||||
String payload = "{\"string\":\"string\",\"unknownProperty\":\"value\"}";
|
||||
Message<?> message = MessageBuilder.withPayload(payload.getBytes(StandardCharsets.UTF_8)).build();
|
||||
|
@ -108,7 +108,7 @@ public class JsonbMessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fromMessageToList() throws Exception {
|
||||
void fromMessageToList() throws Exception {
|
||||
JsonbMessageConverter converter = new JsonbMessageConverter();
|
||||
String payload = "[1, 2, 3, 4, 5, 6, 7, 8, 9]";
|
||||
Message<?> message = MessageBuilder.withPayload(payload.getBytes(StandardCharsets.UTF_8)).build();
|
||||
|
@ -122,7 +122,7 @@ public class JsonbMessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fromMessageToMessageWithPojo() throws Exception {
|
||||
void fromMessageToMessageWithPojo() throws Exception {
|
||||
JsonbMessageConverter converter = new JsonbMessageConverter();
|
||||
String payload = "{\"string\":\"foo\"}";
|
||||
Message<?> message = MessageBuilder.withPayload(payload.getBytes(StandardCharsets.UTF_8)).build();
|
||||
|
@ -136,7 +136,7 @@ public class JsonbMessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void toMessage() {
|
||||
void toMessage() {
|
||||
JsonbMessageConverter converter = new JsonbMessageConverter();
|
||||
MyBean payload = new MyBean();
|
||||
payload.setString("Foo");
|
||||
|
@ -157,7 +157,7 @@ public class JsonbMessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void toMessageUtf16() {
|
||||
void toMessageUtf16() {
|
||||
JsonbMessageConverter converter = new JsonbMessageConverter();
|
||||
MimeType contentType = new MimeType("application", "json", StandardCharsets.UTF_16BE);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
@ -171,7 +171,7 @@ public class JsonbMessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void toMessageUtf16String() {
|
||||
void toMessageUtf16String() {
|
||||
JsonbMessageConverter converter = new JsonbMessageConverter();
|
||||
converter.setSerializedPayloadClass(String.class);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -43,10 +43,10 @@ import static org.assertj.core.api.Assertions.within;
|
|||
* @author Rossen Stoyanchev
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class MappingJackson2MessageConverterTests {
|
||||
class MappingJackson2MessageConverterTests {
|
||||
|
||||
@Test
|
||||
public void defaultConstructor() {
|
||||
void defaultConstructor() {
|
||||
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
|
||||
assertThat(converter.getSupportedMimeTypes()).contains(new MimeType("application", "json"));
|
||||
assertThat(converter.getObjectMapper().getDeserializationConfig()
|
||||
|
@ -73,7 +73,7 @@ public class MappingJackson2MessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fromMessage() {
|
||||
void fromMessage() {
|
||||
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
|
||||
String payload = "{\"bytes\":\"AQI=\",\"array\":[\"Foo\",\"Bar\"]," +
|
||||
"\"number\":42,\"string\":\"Foo\",\"bool\":true,\"fraction\":42.0}";
|
||||
|
@ -89,7 +89,7 @@ public class MappingJackson2MessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fromMessageUntyped() {
|
||||
void fromMessageUntyped() {
|
||||
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
|
||||
String payload = "{\"bytes\":\"AQI=\",\"array\":[\"Foo\",\"Bar\"]," +
|
||||
"\"number\":42,\"string\":\"Foo\",\"bool\":true,\"fraction\":42.0}";
|
||||
|
@ -114,7 +114,7 @@ public class MappingJackson2MessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fromMessageInvalidJson() {
|
||||
void fromMessageInvalidJson() {
|
||||
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
|
||||
String payload = "FooBar";
|
||||
Message<?> message = MessageBuilder.withPayload(payload.getBytes(StandardCharsets.UTF_8)).build();
|
||||
|
@ -123,7 +123,7 @@ public class MappingJackson2MessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fromMessageValidJsonWithUnknownProperty() {
|
||||
void fromMessageValidJsonWithUnknownProperty() {
|
||||
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
|
||||
String payload = "{\"string\":\"string\",\"unknownProperty\":\"value\"}";
|
||||
Message<?> message = MessageBuilder.withPayload(payload.getBytes(StandardCharsets.UTF_8)).build();
|
||||
|
@ -160,7 +160,7 @@ public class MappingJackson2MessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void toMessage() {
|
||||
void toMessage() {
|
||||
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
|
||||
MyBean payload = new MyBean();
|
||||
payload.setString("Foo");
|
||||
|
@ -183,7 +183,7 @@ public class MappingJackson2MessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void toMessageUtf16() {
|
||||
void toMessageUtf16() {
|
||||
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
|
||||
MimeType contentType = new MimeType("application", "json", StandardCharsets.UTF_16BE);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
@ -197,7 +197,7 @@ public class MappingJackson2MessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void toMessageUtf16String() {
|
||||
void toMessageUtf16String() {
|
||||
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
|
||||
converter.setSerializedPayloadClass(String.class);
|
||||
|
||||
|
@ -213,7 +213,7 @@ public class MappingJackson2MessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void toMessageJsonView() throws Exception {
|
||||
void toMessageJsonView() throws Exception {
|
||||
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,7 +16,6 @@
|
|||
|
||||
package org.springframework.messaging.converter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
|
@ -39,13 +38,13 @@ import static org.xmlunit.diff.DifferenceEvaluators.downgradeDifferencesToEqual;
|
|||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class MarshallingMessageConverterTests {
|
||||
class MarshallingMessageConverterTests {
|
||||
|
||||
private MarshallingMessageConverter converter;
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void createMarshaller() throws Exception {
|
||||
void createMarshaller() throws Exception {
|
||||
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
|
||||
marshaller.setClassesToBeBound(MyBean.class);
|
||||
marshaller.afterPropertiesSet();
|
||||
|
@ -55,7 +54,7 @@ public class MarshallingMessageConverterTests {
|
|||
|
||||
|
||||
@Test
|
||||
public void fromMessage() throws Exception {
|
||||
void fromMessage() {
|
||||
String payload = "<myBean><name>Foo</name></myBean>";
|
||||
Message<?> message = MessageBuilder.withPayload(payload.getBytes(StandardCharsets.UTF_8)).build();
|
||||
MyBean actual = (MyBean) this.converter.fromMessage(message, MyBean.class);
|
||||
|
@ -65,7 +64,7 @@ public class MarshallingMessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fromMessageInvalidXml() throws Exception {
|
||||
void fromMessageInvalidXml() {
|
||||
String payload = "<myBean><name>Foo</name><myBean>";
|
||||
Message<?> message = MessageBuilder.withPayload(payload.getBytes(StandardCharsets.UTF_8)).build();
|
||||
assertThatExceptionOfType(MessageConversionException.class).isThrownBy(() ->
|
||||
|
@ -73,7 +72,7 @@ public class MarshallingMessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fromMessageValidXmlWithUnknownProperty() throws IOException {
|
||||
void fromMessageValidXmlWithUnknownProperty() {
|
||||
String payload = "<myBean><age>42</age><myBean>";
|
||||
Message<?> message = MessageBuilder.withPayload(payload.getBytes(StandardCharsets.UTF_8)).build();
|
||||
assertThatExceptionOfType(MessageConversionException.class).isThrownBy(() ->
|
||||
|
@ -81,7 +80,7 @@ public class MarshallingMessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void toMessage() throws Exception {
|
||||
void toMessage() {
|
||||
MyBean payload = new MyBean();
|
||||
payload.setName("Foo");
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -39,13 +39,13 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class MessageConverterTests {
|
||||
class MessageConverterTests {
|
||||
|
||||
private TestMessageConverter converter = new TestMessageConverter();
|
||||
|
||||
|
||||
@Test
|
||||
public void supportsTargetClass() {
|
||||
void supportsTargetClass() {
|
||||
Message<String> message = MessageBuilder.withPayload("ABC").build();
|
||||
|
||||
assertThat(this.converter.fromMessage(message, String.class)).isEqualTo("success-from");
|
||||
|
@ -53,7 +53,7 @@ public class MessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void supportsMimeType() {
|
||||
void supportsMimeType() {
|
||||
Message<String> message = MessageBuilder.withPayload(
|
||||
"ABC").setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN).build();
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class MessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void supportsMimeTypeNotSupported() {
|
||||
void supportsMimeTypeNotSupported() {
|
||||
Message<String> message = MessageBuilder.withPayload(
|
||||
"ABC").setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON).build();
|
||||
|
||||
|
@ -69,13 +69,13 @@ public class MessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void supportsMimeTypeNotSpecified() {
|
||||
void supportsMimeTypeNotSpecified() {
|
||||
Message<String> message = MessageBuilder.withPayload("ABC").build();
|
||||
assertThat(this.converter.fromMessage(message, String.class)).isEqualTo("success-from");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void supportsMimeTypeNoneConfigured() {
|
||||
void supportsMimeTypeNoneConfigured() {
|
||||
Message<String> message = MessageBuilder.withPayload(
|
||||
"ABC").setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON).build();
|
||||
this.converter = new TestMessageConverter(new MimeType[0]);
|
||||
|
@ -84,7 +84,7 @@ public class MessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void canConvertFromStrictContentTypeMatch() {
|
||||
void canConvertFromStrictContentTypeMatch() {
|
||||
this.converter = new TestMessageConverter(MimeTypeUtils.TEXT_PLAIN);
|
||||
this.converter.setStrictContentTypeMatch(true);
|
||||
|
||||
|
@ -98,13 +98,13 @@ public class MessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void setStrictContentTypeMatchWithNoSupportedMimeTypes() {
|
||||
void setStrictContentTypeMatchWithNoSupportedMimeTypes() {
|
||||
this.converter = new TestMessageConverter(new MimeType[0]);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.converter.setStrictContentTypeMatch(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toMessageWithHeaders() {
|
||||
void toMessageWithHeaders() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("foo", "bar");
|
||||
MessageHeaders headers = new MessageHeaders(map);
|
||||
|
@ -117,7 +117,7 @@ public class MessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void toMessageWithMutableMessageHeaders() {
|
||||
void toMessageWithMutableMessageHeaders() {
|
||||
SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.create(SimpMessageType.MESSAGE);
|
||||
accessor.setHeader("foo", "bar");
|
||||
accessor.setNativeHeader("fooNative", "barNative");
|
||||
|
@ -133,7 +133,7 @@ public class MessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void toMessageContentTypeHeader() {
|
||||
void toMessageContentTypeHeader() {
|
||||
Message<?> message = this.converter.toMessage("ABC", null);
|
||||
assertThat(message.getHeaders().get(MessageHeaders.CONTENT_TYPE)).isEqualTo(MimeTypeUtils.TEXT_PLAIN);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -32,14 +32,14 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class SimpleMessageConverterTests {
|
||||
class SimpleMessageConverterTests {
|
||||
|
||||
private final SimpleMessageConverter converter = new SimpleMessageConverter();
|
||||
|
||||
|
||||
@Test
|
||||
public void toMessageWithPayloadAndHeaders() {
|
||||
MessageHeaders headers = new MessageHeaders(Collections.<String, Object>singletonMap("foo", "bar"));
|
||||
void toMessageWithPayloadAndHeaders() {
|
||||
MessageHeaders headers = new MessageHeaders(Collections.singletonMap("foo", "bar"));
|
||||
Message<?> message = this.converter.toMessage("payload", headers);
|
||||
|
||||
assertThat(message.getPayload()).isEqualTo("payload");
|
||||
|
@ -47,7 +47,7 @@ public class SimpleMessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void toMessageWithPayloadAndMutableHeaders() {
|
||||
void toMessageWithPayloadAndMutableHeaders() {
|
||||
MessageHeaderAccessor accessor = new MessageHeaderAccessor();
|
||||
accessor.setHeader("foo", "bar");
|
||||
accessor.setLeaveMutable(true);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -35,33 +35,33 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class StringMessageConverterTests {
|
||||
class StringMessageConverterTests {
|
||||
|
||||
private final StringMessageConverter converter = new StringMessageConverter();
|
||||
|
||||
|
||||
@Test
|
||||
public void fromByteArrayMessage() {
|
||||
void fromByteArrayMessage() {
|
||||
Message<byte[]> message = MessageBuilder.withPayload(
|
||||
"ABC".getBytes()).setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN).build();
|
||||
assertThat(this.converter.fromMessage(message, String.class)).isEqualTo("ABC");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromStringMessage() {
|
||||
void fromStringMessage() {
|
||||
Message<String> message = MessageBuilder.withPayload(
|
||||
"ABC").setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN).build();
|
||||
assertThat(this.converter.fromMessage(message, String.class)).isEqualTo("ABC");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromMessageNoContentTypeHeader() {
|
||||
void fromMessageNoContentTypeHeader() {
|
||||
Message<byte[]> message = MessageBuilder.withPayload("ABC".getBytes()).build();
|
||||
assertThat(this.converter.fromMessage(message, String.class)).isEqualTo("ABC");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromMessageCharset() {
|
||||
void fromMessageCharset() {
|
||||
String payload = "H\u00e9llo W\u00f6rld";
|
||||
Message<byte[]> message = MessageBuilder.withPayload(payload.getBytes(StandardCharsets.ISO_8859_1))
|
||||
.setHeader(MessageHeaders.CONTENT_TYPE, new MimeType("text", "plain", StandardCharsets.ISO_8859_1)).build();
|
||||
|
@ -69,27 +69,27 @@ public class StringMessageConverterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fromMessageDefaultCharset() {
|
||||
void fromMessageDefaultCharset() {
|
||||
String payload = "H\u00e9llo W\u00f6rld";
|
||||
Message<byte[]> message = MessageBuilder.withPayload(payload.getBytes(StandardCharsets.UTF_8)).build();
|
||||
assertThat(this.converter.fromMessage(message, String.class)).isEqualTo(payload);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromMessageTargetClassNotSupported() {
|
||||
void fromMessageTargetClassNotSupported() {
|
||||
Message<byte[]> message = MessageBuilder.withPayload("ABC".getBytes()).build();
|
||||
assertThat(this.converter.fromMessage(message, Integer.class)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromMessageByteArray() {
|
||||
void fromMessageByteArray() {
|
||||
Message<byte[]> message = MessageBuilder.withPayload(
|
||||
"ABC".getBytes()).setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN).build();
|
||||
assertThat(this.converter.fromMessage(message, String.class)).isEqualTo("ABC");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toMessage() {
|
||||
void toMessage() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN);
|
||||
MessageHeaders headers = new MessageHeaders(map);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -31,11 +31,10 @@ import static org.mockito.Mockito.verify;
|
|||
* @author Agim Emruli
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class CachingDestinationResolverTests {
|
||||
class CachingDestinationResolverTests {
|
||||
|
||||
@Test
|
||||
public void cachedDestination() {
|
||||
@SuppressWarnings("unchecked")
|
||||
void cachedDestination() {
|
||||
DestinationResolver<String> resolver = mock();
|
||||
CachingDestinationResolverProxy<String> resolverProxy = new CachingDestinationResolverProxy<>(resolver);
|
||||
|
||||
|
@ -52,14 +51,14 @@ public class CachingDestinationResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void noTargetSet() {
|
||||
void noTargetSet() {
|
||||
CachingDestinationResolverProxy<String> resolverProxy = new CachingDestinationResolverProxy<>();
|
||||
assertThatIllegalArgumentException().isThrownBy(
|
||||
resolverProxy::afterPropertiesSet);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullTargetThroughConstructor() {
|
||||
void nullTargetThroughConstructor() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new CachingDestinationResolverProxy<String>(null));
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class DestinationResolvingMessagingTemplateTests {
|
||||
class DestinationResolvingMessagingTemplateTests {
|
||||
|
||||
private TestDestinationResolvingMessagingTemplate template;
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class DestinationResolvingMessagingTemplateTests {
|
|||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
void setup() {
|
||||
|
||||
TestMessageChannelDestinationResolver resolver = new TestMessageChannelDestinationResolver();
|
||||
|
||||
|
@ -58,14 +58,14 @@ public class DestinationResolvingMessagingTemplateTests {
|
|||
this.template = new TestDestinationResolvingMessagingTemplate();
|
||||
this.template.setDestinationResolver(resolver);
|
||||
|
||||
this.headers = Collections.<String, Object>singletonMap("key", "value");
|
||||
this.headers = Collections.singletonMap("key", "value");
|
||||
|
||||
this.postProcessor = new TestMessagePostProcessor();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void send() {
|
||||
void send() {
|
||||
Message<?> message = new GenericMessage<Object>("payload");
|
||||
this.template.send("myChannel", message);
|
||||
|
||||
|
@ -74,14 +74,14 @@ public class DestinationResolvingMessagingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendNoDestinationResolver() {
|
||||
void sendNoDestinationResolver() {
|
||||
TestDestinationResolvingMessagingTemplate template = new TestDestinationResolvingMessagingTemplate();
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
template.send("myChannel", new GenericMessage<Object>("payload")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertAndSendPayload() {
|
||||
void convertAndSendPayload() {
|
||||
this.template.convertAndSend("myChannel", "payload");
|
||||
|
||||
assertThat(this.template.messageChannel).isSameAs(this.myChannel);
|
||||
|
@ -90,7 +90,7 @@ public class DestinationResolvingMessagingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void convertAndSendPayloadAndHeaders() {
|
||||
void convertAndSendPayloadAndHeaders() {
|
||||
this.template.convertAndSend("myChannel", "payload", this.headers);
|
||||
|
||||
assertThat(this.template.messageChannel).isSameAs(this.myChannel);
|
||||
|
@ -100,7 +100,7 @@ public class DestinationResolvingMessagingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void convertAndSendPayloadWithPostProcessor() {
|
||||
void convertAndSendPayloadWithPostProcessor() {
|
||||
this.template.convertAndSend("myChannel", "payload", this.postProcessor);
|
||||
|
||||
assertThat(this.template.messageChannel).isSameAs(this.myChannel);
|
||||
|
@ -112,7 +112,7 @@ public class DestinationResolvingMessagingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void convertAndSendPayloadAndHeadersWithPostProcessor() {
|
||||
void convertAndSendPayloadAndHeadersWithPostProcessor() {
|
||||
this.template.convertAndSend("myChannel", "payload", this.headers, this.postProcessor);
|
||||
|
||||
assertThat(this.template.messageChannel).isSameAs(this.myChannel);
|
||||
|
@ -125,7 +125,7 @@ public class DestinationResolvingMessagingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void receive() {
|
||||
void receive() {
|
||||
Message<?> expected = new GenericMessage<Object>("payload");
|
||||
this.template.setReceiveMessage(expected);
|
||||
Message<?> actual = this.template.receive("myChannel");
|
||||
|
@ -135,7 +135,7 @@ public class DestinationResolvingMessagingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void receiveAndConvert() {
|
||||
void receiveAndConvert() {
|
||||
Message<?> expected = new GenericMessage<Object>("payload");
|
||||
this.template.setReceiveMessage(expected);
|
||||
String payload = this.template.receiveAndConvert("myChannel", String.class);
|
||||
|
@ -145,7 +145,7 @@ public class DestinationResolvingMessagingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendAndReceive() {
|
||||
void sendAndReceive() {
|
||||
Message<?> requestMessage = new GenericMessage<Object>("request");
|
||||
Message<?> responseMessage = new GenericMessage<Object>("response");
|
||||
this.template.setReceiveMessage(responseMessage);
|
||||
|
@ -157,7 +157,7 @@ public class DestinationResolvingMessagingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void convertSendAndReceive() {
|
||||
void convertSendAndReceive() {
|
||||
Message<?> responseMessage = new GenericMessage<Object>("response");
|
||||
this.template.setReceiveMessage(responseMessage);
|
||||
String actual = this.template.convertSendAndReceive("myChannel", "request", String.class);
|
||||
|
@ -168,7 +168,7 @@ public class DestinationResolvingMessagingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void convertSendAndReceiveWithHeaders() {
|
||||
void convertSendAndReceiveWithHeaders() {
|
||||
Message<?> responseMessage = new GenericMessage<Object>("response");
|
||||
this.template.setReceiveMessage(responseMessage);
|
||||
String actual = this.template.convertSendAndReceive("myChannel", "request", this.headers, String.class);
|
||||
|
@ -180,7 +180,7 @@ public class DestinationResolvingMessagingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void convertSendAndReceiveWithPostProcessor() {
|
||||
void convertSendAndReceiveWithPostProcessor() {
|
||||
Message<?> responseMessage = new GenericMessage<Object>("response");
|
||||
this.template.setReceiveMessage(responseMessage);
|
||||
String actual = this.template.convertSendAndReceive("myChannel", "request", String.class, this.postProcessor);
|
||||
|
@ -192,7 +192,7 @@ public class DestinationResolvingMessagingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void convertSendAndReceiveWithHeadersAndPostProcessor() {
|
||||
void convertSendAndReceiveWithHeadersAndPostProcessor() {
|
||||
Message<?> responseMessage = new GenericMessage<Object>("response");
|
||||
this.template.setReceiveMessage(responseMessage);
|
||||
String actual = this.template.convertSendAndReceive("myChannel", "request", this.headers,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -51,7 +51,7 @@ import static org.mockito.Mockito.verify;
|
|||
* @author Rossen Stoyanchev
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class GenericMessagingTemplateTests {
|
||||
class GenericMessagingTemplateTests {
|
||||
|
||||
private GenericMessagingTemplate template;
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class GenericMessagingTemplateTests {
|
|||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
void setup() {
|
||||
this.messageChannel = new StubMessageChannel();
|
||||
this.template = new GenericMessagingTemplate();
|
||||
this.template.setDefaultDestination(this.messageChannel);
|
||||
|
@ -71,7 +71,7 @@ public class GenericMessagingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendWithTimeout() {
|
||||
void sendWithTimeout() {
|
||||
SubscribableChannel channel = mock();
|
||||
final AtomicReference<Message<?>> sent = new AtomicReference<>();
|
||||
willAnswer(invocation -> {
|
||||
|
@ -90,7 +90,7 @@ public class GenericMessagingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendWithTimeoutMutable() {
|
||||
void sendWithTimeoutMutable() {
|
||||
SubscribableChannel channel = mock();
|
||||
final AtomicReference<Message<?>> sent = new AtomicReference<>();
|
||||
willAnswer(invocation -> {
|
||||
|
@ -109,7 +109,7 @@ public class GenericMessagingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendAndReceive() {
|
||||
void sendAndReceive() {
|
||||
SubscribableChannel channel = new ExecutorSubscribableChannel(this.executor);
|
||||
channel.subscribe(message -> {
|
||||
MessageChannel replyChannel = (MessageChannel) message.getHeaders().getReplyChannel();
|
||||
|
@ -121,7 +121,7 @@ public class GenericMessagingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendAndReceiveTimeout() throws InterruptedException {
|
||||
void sendAndReceiveTimeout() throws InterruptedException {
|
||||
final AtomicReference<Throwable> failure = new AtomicReference<>();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
|
||||
|
@ -147,7 +147,7 @@ public class GenericMessagingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendAndReceiveVariableTimeout() throws InterruptedException {
|
||||
void sendAndReceiveVariableTimeout() throws InterruptedException {
|
||||
final AtomicReference<Throwable> failure = new AtomicReference<>();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
|
||||
|
@ -177,7 +177,7 @@ public class GenericMessagingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendAndReceiveVariableTimeoutCustomHeaders() throws InterruptedException {
|
||||
void sendAndReceiveVariableTimeoutCustomHeaders() throws InterruptedException {
|
||||
final AtomicReference<Throwable> failure = new AtomicReference<>();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
|
||||
|
@ -209,7 +209,7 @@ public class GenericMessagingTemplateTests {
|
|||
}
|
||||
|
||||
private MessageHandler createLateReplier(final CountDownLatch latch, final AtomicReference<Throwable> failure) {
|
||||
MessageHandler handler = message -> {
|
||||
return message -> {
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
MessageChannel replyChannel = (MessageChannel) message.getHeaders().getReplyChannel();
|
||||
|
@ -231,11 +231,10 @@ public class GenericMessagingTemplateTests {
|
|||
latch.countDown();
|
||||
}
|
||||
};
|
||||
return handler;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertAndSendWithSimpMessageHeaders() {
|
||||
void convertAndSendWithSimpMessageHeaders() {
|
||||
MessageHeaderAccessor accessor = new MessageHeaderAccessor();
|
||||
accessor.setHeader("key", "value");
|
||||
accessor.setLeaveMutable(true);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -37,18 +37,18 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
|||
* @author Rossen Stoyanchev
|
||||
* @see MessageRequestReplyTemplateTests
|
||||
*/
|
||||
public class MessageReceivingTemplateTests {
|
||||
class MessageReceivingTemplateTests {
|
||||
|
||||
private TestMessagingTemplate template;
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
void setup() {
|
||||
this.template = new TestMessagingTemplate();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void receive() {
|
||||
void receive() {
|
||||
Message<?> expected = new GenericMessage<>("payload");
|
||||
this.template.setDefaultDestination("home");
|
||||
this.template.setReceiveMessage(expected);
|
||||
|
@ -59,13 +59,13 @@ public class MessageReceivingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void receiveMissingDefaultDestination() {
|
||||
void receiveMissingDefaultDestination() {
|
||||
assertThatIllegalStateException().isThrownBy(
|
||||
this.template::receive);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void receiveFromDestination() {
|
||||
void receiveFromDestination() {
|
||||
Message<?> expected = new GenericMessage<>("payload");
|
||||
this.template.setReceiveMessage(expected);
|
||||
Message<?> actual = this.template.receive("somewhere");
|
||||
|
@ -75,7 +75,7 @@ public class MessageReceivingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void receiveAndConvert() {
|
||||
void receiveAndConvert() {
|
||||
Message<?> expected = new GenericMessage<>("payload");
|
||||
this.template.setDefaultDestination("home");
|
||||
this.template.setReceiveMessage(expected);
|
||||
|
@ -86,7 +86,7 @@ public class MessageReceivingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void receiveAndConvertFromDestination() {
|
||||
void receiveAndConvertFromDestination() {
|
||||
Message<?> expected = new GenericMessage<>("payload");
|
||||
this.template.setReceiveMessage(expected);
|
||||
String payload = this.template.receiveAndConvert("somewhere", String.class);
|
||||
|
@ -96,7 +96,7 @@ public class MessageReceivingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void receiveAndConvertFailed() {
|
||||
void receiveAndConvertFailed() {
|
||||
Message<?> expected = new GenericMessage<>("not a number test");
|
||||
this.template.setReceiveMessage(expected);
|
||||
this.template.setMessageConverter(new GenericMessageConverter());
|
||||
|
@ -107,7 +107,7 @@ public class MessageReceivingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void receiveAndConvertNoConverter() {
|
||||
void receiveAndConvertNoConverter() {
|
||||
Message<?> expected = new GenericMessage<>("payload");
|
||||
this.template.setDefaultDestination("home");
|
||||
this.template.setReceiveMessage(expected);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
|||
*
|
||||
* @see MessageReceivingTemplateTests
|
||||
*/
|
||||
public class MessageRequestReplyTemplateTests {
|
||||
class MessageRequestReplyTemplateTests {
|
||||
|
||||
private TestMessagingTemplate template;
|
||||
|
||||
|
@ -45,15 +45,15 @@ public class MessageRequestReplyTemplateTests {
|
|||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
void setup() {
|
||||
this.template = new TestMessagingTemplate();
|
||||
this.postProcessor = new TestMessagePostProcessor();
|
||||
this.headers = Collections.<String, Object>singletonMap("key", "value");
|
||||
this.headers = Collections.singletonMap("key", "value");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void sendAndReceive() {
|
||||
void sendAndReceive() {
|
||||
Message<?> requestMessage = new GenericMessage<Object>("request");
|
||||
Message<?> responseMessage = new GenericMessage<Object>("response");
|
||||
this.template.setDefaultDestination("home");
|
||||
|
@ -66,13 +66,13 @@ public class MessageRequestReplyTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendAndReceiveMissingDestination() {
|
||||
void sendAndReceiveMissingDestination() {
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
this.template.sendAndReceive(new GenericMessage<Object>("request")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sendAndReceiveToDestination() {
|
||||
void sendAndReceiveToDestination() {
|
||||
Message<?> requestMessage = new GenericMessage<Object>("request");
|
||||
Message<?> responseMessage = new GenericMessage<Object>("response");
|
||||
this.template.setReceiveMessage(responseMessage);
|
||||
|
@ -84,7 +84,7 @@ public class MessageRequestReplyTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void convertAndSend() {
|
||||
void convertAndSend() {
|
||||
Message<?> responseMessage = new GenericMessage<Object>("response");
|
||||
this.template.setDefaultDestination("home");
|
||||
this.template.setReceiveMessage(responseMessage);
|
||||
|
@ -96,7 +96,7 @@ public class MessageRequestReplyTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void convertAndSendToDestination() {
|
||||
void convertAndSendToDestination() {
|
||||
Message<?> responseMessage = new GenericMessage<Object>("response");
|
||||
this.template.setReceiveMessage(responseMessage);
|
||||
String response = this.template.convertSendAndReceive("somewhere", "request", String.class);
|
||||
|
@ -107,7 +107,7 @@ public class MessageRequestReplyTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void convertAndSendToDestinationWithHeaders() {
|
||||
void convertAndSendToDestinationWithHeaders() {
|
||||
Message<?> responseMessage = new GenericMessage<Object>("response");
|
||||
this.template.setReceiveMessage(responseMessage);
|
||||
String response = this.template.convertSendAndReceive("somewhere", "request", this.headers, String.class);
|
||||
|
@ -119,7 +119,7 @@ public class MessageRequestReplyTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void convertAndSendWithPostProcessor() {
|
||||
void convertAndSendWithPostProcessor() {
|
||||
Message<?> responseMessage = new GenericMessage<Object>("response");
|
||||
this.template.setDefaultDestination("home");
|
||||
this.template.setReceiveMessage(responseMessage);
|
||||
|
@ -132,7 +132,7 @@ public class MessageRequestReplyTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void convertAndSendToDestinationWithPostProcessor() {
|
||||
void convertAndSendToDestinationWithPostProcessor() {
|
||||
Message<?> responseMessage = new GenericMessage<Object>("response");
|
||||
this.template.setReceiveMessage(responseMessage);
|
||||
String response = this.template.convertSendAndReceive("somewhere", "request", String.class, this.postProcessor);
|
||||
|
@ -144,7 +144,7 @@ public class MessageRequestReplyTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void convertAndSendToDestinationWithHeadersAndPostProcessor() {
|
||||
void convertAndSendToDestinationWithHeadersAndPostProcessor() {
|
||||
Message<?> responseMessage = new GenericMessage<Object>("response");
|
||||
this.template.setReceiveMessage(responseMessage);
|
||||
String response = this.template.convertSendAndReceive("somewhere", "request", this.headers,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -17,8 +17,8 @@
|
|||
package org.springframework.messaging.core;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class MessageSendingTemplateTests {
|
||||
class MessageSendingTemplateTests {
|
||||
|
||||
private TestMessageSendingTemplate template;
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class MessageSendingTemplateTests {
|
|||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
void setup() {
|
||||
this.template = new TestMessageSendingTemplate();
|
||||
this.postProcessor = new TestMessagePostProcessor();
|
||||
this.headers = new HashMap<>();
|
||||
|
@ -63,7 +63,7 @@ public class MessageSendingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void send() {
|
||||
void send() {
|
||||
Message<?> message = new GenericMessage<Object>("payload");
|
||||
this.template.setDefaultDestination("home");
|
||||
this.template.send(message);
|
||||
|
@ -73,7 +73,7 @@ public class MessageSendingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendToDestination() {
|
||||
void sendToDestination() {
|
||||
Message<?> message = new GenericMessage<Object>("payload");
|
||||
this.template.send("somewhere", message);
|
||||
|
||||
|
@ -82,14 +82,14 @@ public class MessageSendingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendMissingDestination() {
|
||||
void sendMissingDestination() {
|
||||
Message<?> message = new GenericMessage<Object>("payload");
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
this.template.send(message));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertAndSend() {
|
||||
void convertAndSend() {
|
||||
this.template.convertAndSend("somewhere", "payload", headers, this.postProcessor);
|
||||
|
||||
assertThat(this.template.destination).isEqualTo("somewhere");
|
||||
|
@ -102,7 +102,7 @@ public class MessageSendingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void convertAndSendPayload() {
|
||||
void convertAndSendPayload() {
|
||||
this.template.setDefaultDestination("home");
|
||||
this.template.convertAndSend("payload");
|
||||
|
||||
|
@ -113,7 +113,7 @@ public class MessageSendingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void convertAndSendPayloadToDestination() {
|
||||
void convertAndSendPayloadToDestination() {
|
||||
this.template.convertAndSend("somewhere", "payload");
|
||||
|
||||
assertThat(this.template.destination).isEqualTo("somewhere");
|
||||
|
@ -123,7 +123,7 @@ public class MessageSendingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void convertAndSendPayloadAndHeadersToDestination() {
|
||||
void convertAndSendPayloadAndHeadersToDestination() {
|
||||
this.template.convertAndSend("somewhere", "payload", headers);
|
||||
|
||||
assertThat(this.template.destination).isEqualTo("somewhere");
|
||||
|
@ -133,7 +133,7 @@ public class MessageSendingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void convertAndSendPayloadAndMutableHeadersToDestination() {
|
||||
void convertAndSendPayloadAndMutableHeadersToDestination() {
|
||||
MessageHeaderAccessor accessor = new MessageHeaderAccessor();
|
||||
accessor.setHeader("foo", "bar");
|
||||
accessor.setLeaveMutable(true);
|
||||
|
@ -149,7 +149,7 @@ public class MessageSendingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void convertAndSendPayloadWithPostProcessor() {
|
||||
void convertAndSendPayloadWithPostProcessor() {
|
||||
this.template.setDefaultDestination("home");
|
||||
this.template.convertAndSend((Object) "payload", this.postProcessor);
|
||||
|
||||
|
@ -163,7 +163,7 @@ public class MessageSendingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void convertAndSendPayloadWithPostProcessorToDestination() {
|
||||
void convertAndSendPayloadWithPostProcessorToDestination() {
|
||||
this.template.convertAndSend("somewhere", "payload", this.postProcessor);
|
||||
|
||||
assertThat(this.template.destination).isEqualTo("somewhere");
|
||||
|
@ -176,10 +176,10 @@ public class MessageSendingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void convertAndSendNoMatchingConverter() {
|
||||
void convertAndSendNoMatchingConverter() {
|
||||
|
||||
MessageConverter converter = new CompositeMessageConverter(
|
||||
Arrays.<MessageConverter>asList(new MappingJackson2MessageConverter()));
|
||||
List.of(new MappingJackson2MessageConverter()));
|
||||
this.template.setMessageConverter(converter);
|
||||
|
||||
this.headers.put(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_XML);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -29,32 +29,34 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class DestinationPatternsMessageConditionTests {
|
||||
class DestinationPatternsMessageConditionTests {
|
||||
|
||||
@Test
|
||||
public void prependSlash() {
|
||||
void prependSlash() {
|
||||
DestinationPatternsMessageCondition c = condition("foo");
|
||||
assertThat(c.getPatterns()).element(0).isEqualTo("/foo");
|
||||
assertThat(c.getPatterns()).containsExactly("/foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void prependSlashWithCustomPathSeparator() {
|
||||
void prependSlashWithCustomPathSeparator() {
|
||||
DestinationPatternsMessageCondition c =
|
||||
new DestinationPatternsMessageCondition(new String[] {"foo"}, new AntPathMatcher("."));
|
||||
|
||||
assertThat(c.getPatterns()).element(0).as("Pre-pending should be disabled when not using '/' as path separator").isEqualTo("foo");
|
||||
assertThat(c.getPatterns())
|
||||
.as("Pre-pending should be disabled when not using '/' as path separator")
|
||||
.containsExactly("foo");
|
||||
}
|
||||
|
||||
// SPR-8255
|
||||
|
||||
@Test
|
||||
public void prependNonEmptyPatternsOnly() {
|
||||
void prependNonEmptyPatternsOnly() {
|
||||
DestinationPatternsMessageCondition c = condition("");
|
||||
assertThat(c.getPatterns()).element(0).asString().isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void combineEmptySets() {
|
||||
void combineEmptySets() {
|
||||
DestinationPatternsMessageCondition c1 = condition();
|
||||
DestinationPatternsMessageCondition c2 = condition();
|
||||
|
||||
|
@ -62,7 +64,7 @@ public class DestinationPatternsMessageConditionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void combineOnePatternWithEmptySet() {
|
||||
void combineOnePatternWithEmptySet() {
|
||||
DestinationPatternsMessageCondition c1 = condition("/type1", "/type2");
|
||||
DestinationPatternsMessageCondition c2 = condition();
|
||||
|
||||
|
@ -75,7 +77,7 @@ public class DestinationPatternsMessageConditionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void combineMultiplePatterns() {
|
||||
void combineMultiplePatterns() {
|
||||
DestinationPatternsMessageCondition c1 = condition("/t1", "/t2");
|
||||
DestinationPatternsMessageCondition c2 = condition("/m1", "/m2");
|
||||
|
||||
|
@ -84,7 +86,7 @@ public class DestinationPatternsMessageConditionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void matchDirectPath() {
|
||||
void matchDirectPath() {
|
||||
DestinationPatternsMessageCondition condition = condition("/foo");
|
||||
DestinationPatternsMessageCondition match = condition.getMatchingCondition(messageTo("/foo"));
|
||||
|
||||
|
@ -92,7 +94,7 @@ public class DestinationPatternsMessageConditionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void matchPattern() {
|
||||
void matchPattern() {
|
||||
DestinationPatternsMessageCondition condition = condition("/foo/*");
|
||||
DestinationPatternsMessageCondition match = condition.getMatchingCondition(messageTo("/foo/bar"));
|
||||
|
||||
|
@ -100,7 +102,7 @@ public class DestinationPatternsMessageConditionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void matchSortPatterns() {
|
||||
void matchSortPatterns() {
|
||||
DestinationPatternsMessageCondition condition = condition("/**", "/foo/bar", "/foo/*");
|
||||
DestinationPatternsMessageCondition match = condition.getMatchingCondition(messageTo("/foo/bar"));
|
||||
DestinationPatternsMessageCondition expected = condition("/foo/bar", "/foo/*", "/**");
|
||||
|
@ -109,7 +111,7 @@ public class DestinationPatternsMessageConditionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void compareEqualPatterns() {
|
||||
void compareEqualPatterns() {
|
||||
DestinationPatternsMessageCondition c1 = condition("/foo*");
|
||||
DestinationPatternsMessageCondition c2 = condition("/foo*");
|
||||
|
||||
|
@ -117,7 +119,7 @@ public class DestinationPatternsMessageConditionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void comparePatternSpecificity() {
|
||||
void comparePatternSpecificity() {
|
||||
DestinationPatternsMessageCondition c1 = condition("/fo*");
|
||||
DestinationPatternsMessageCondition c2 = condition("/foo");
|
||||
|
||||
|
@ -125,7 +127,7 @@ public class DestinationPatternsMessageConditionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void compareNumberOfMatchingPatterns() throws Exception {
|
||||
void compareNumberOfMatchingPatterns() {
|
||||
Message<?> message = messageTo("/foo");
|
||||
|
||||
DestinationPatternsMessageCondition c1 = condition("/foo", "bar");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class MessageMappingReflectiveProcessorTests {
|
||||
class MessageMappingReflectiveProcessorTests {
|
||||
|
||||
private final MessageMappingReflectiveProcessor processor = new MessageMappingReflectiveProcessor();
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -38,7 +38,7 @@ import static org.springframework.messaging.handler.annotation.MessagingPredicat
|
|||
* Test fixture for {@link DestinationVariableMethodArgumentResolver} tests.
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class DestinationVariableMethodArgumentResolverTests {
|
||||
class DestinationVariableMethodArgumentResolverTests {
|
||||
|
||||
private final DestinationVariableMethodArgumentResolver resolver =
|
||||
new DestinationVariableMethodArgumentResolver(new DefaultConversionService());
|
||||
|
@ -48,13 +48,13 @@ public class DestinationVariableMethodArgumentResolverTests {
|
|||
|
||||
|
||||
@Test
|
||||
public void supportsParameter() {
|
||||
void supportsParameter() {
|
||||
assertThat(resolver.supportsParameter(this.resolvable.annot(destinationVar().noValue()).arg())).isTrue();
|
||||
assertThat(resolver.supportsParameter(this.resolvable.annotNotPresent(DestinationVariable.class).arg())).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveArgument() {
|
||||
void resolveArgument() {
|
||||
|
||||
Map<String, Object> vars = new HashMap<>();
|
||||
vars.put("foo", "bar");
|
||||
|
@ -71,7 +71,7 @@ public class DestinationVariableMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveArgumentNotFound() {
|
||||
void resolveArgumentNotFound() {
|
||||
Message<byte[]> message = MessageBuilder.withPayload(new byte[0]).build();
|
||||
assertThatExceptionOfType(MessageHandlingException.class).isThrownBy(() ->
|
||||
resolveArgument(this.resolvable.annot(destinationVar().noValue()).arg(), message));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -43,7 +43,7 @@ import static org.springframework.messaging.handler.annotation.MessagingPredicat
|
|||
* Test fixture for {@link HeaderMethodArgumentResolver} tests.
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class HeaderMethodArgumentResolverTests {
|
||||
class HeaderMethodArgumentResolverTests {
|
||||
|
||||
private HeaderMethodArgumentResolver resolver;
|
||||
|
||||
|
@ -51,7 +51,6 @@ public class HeaderMethodArgumentResolverTests {
|
|||
|
||||
|
||||
@BeforeEach
|
||||
@SuppressWarnings("resource")
|
||||
public void setup() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
context.refresh();
|
||||
|
@ -60,13 +59,13 @@ public class HeaderMethodArgumentResolverTests {
|
|||
|
||||
|
||||
@Test
|
||||
public void supportsParameter() {
|
||||
void supportsParameter() {
|
||||
assertThat(this.resolver.supportsParameter(this.resolvable.annot(headerPlain()).arg())).isTrue();
|
||||
assertThat(this.resolver.supportsParameter(this.resolvable.annotNotPresent(Header.class).arg())).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveArgument() {
|
||||
void resolveArgument() {
|
||||
Message<byte[]> message = MessageBuilder.withPayload(new byte[0]).setHeader("param1", "foo").build();
|
||||
Object result = resolveArgument(this.resolvable.annot(headerPlain()).arg(), message);
|
||||
assertThat(result).isEqualTo("foo");
|
||||
|
@ -81,7 +80,7 @@ public class HeaderMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveArgumentNativeHeaderAmbiguity() {
|
||||
void resolveArgumentNativeHeaderAmbiguity() {
|
||||
TestMessageHeaderAccessor headers = new TestMessageHeaderAccessor();
|
||||
headers.setHeader("param1", "foo");
|
||||
headers.setNativeHeader("param1", "native-foo");
|
||||
|
@ -95,21 +94,21 @@ public class HeaderMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveArgumentNotFound() {
|
||||
void resolveArgumentNotFound() {
|
||||
Message<byte[]> message = MessageBuilder.withPayload(new byte[0]).build();
|
||||
assertThatExceptionOfType(MessageHandlingException.class).isThrownBy(() ->
|
||||
resolveArgument(this.resolvable.annot(headerPlain()).arg(), message));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveArgumentDefaultValue() {
|
||||
void resolveArgumentDefaultValue() {
|
||||
Message<byte[]> message = MessageBuilder.withPayload(new byte[0]).build();
|
||||
Object result = resolveArgument(this.resolvable.annot(header("name", "bar")).arg(), message);
|
||||
assertThat(result).isEqualTo("bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveDefaultValueSystemProperty() {
|
||||
void resolveDefaultValueSystemProperty() {
|
||||
System.setProperty("systemProperty", "sysbar");
|
||||
try {
|
||||
Message<byte[]> message = MessageBuilder.withPayload(new byte[0]).build();
|
||||
|
@ -123,7 +122,7 @@ public class HeaderMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveNameFromSystemProperty() {
|
||||
void resolveNameFromSystemProperty() {
|
||||
System.setProperty("systemProperty", "sysbar");
|
||||
try {
|
||||
Message<byte[]> message = MessageBuilder.withPayload(new byte[0]).setHeader("sysbar", "foo").build();
|
||||
|
@ -137,7 +136,7 @@ public class HeaderMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveOptionalHeaderWithValue() {
|
||||
void resolveOptionalHeaderWithValue() {
|
||||
Message<String> message = MessageBuilder.withPayload("foo").setHeader("foo", "bar").build();
|
||||
MethodParameter param = this.resolvable.annot(header("foo")).arg(Optional.class, String.class);
|
||||
Object result = resolveArgument(param, message);
|
||||
|
@ -145,7 +144,7 @@ public class HeaderMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveOptionalHeaderAsEmpty() {
|
||||
void resolveOptionalHeaderAsEmpty() {
|
||||
Message<String> message = MessageBuilder.withPayload("foo").build();
|
||||
MethodParameter param = this.resolvable.annot(header("foo")).arg(Optional.class, String.class);
|
||||
Object result = resolveArgument(param, message);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
|||
* Test fixture for {@link HeadersMethodArgumentResolver} tests.
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class HeadersMethodArgumentResolverTests {
|
||||
class HeadersMethodArgumentResolverTests {
|
||||
|
||||
private final HeadersMethodArgumentResolver resolver = new HeadersMethodArgumentResolver();
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class HeadersMethodArgumentResolverTests {
|
|||
|
||||
|
||||
@Test
|
||||
public void supportsParameter() {
|
||||
void supportsParameter() {
|
||||
|
||||
assertThat(this.resolver.supportsParameter(
|
||||
this.resolvable.annotPresent(Headers.class).arg(Map.class, String.class, Object.class))).isTrue();
|
||||
|
@ -62,7 +62,6 @@ public class HeadersMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void resolveArgumentAnnotated() {
|
||||
MethodParameter param = this.resolvable.annotPresent(Headers.class).arg(Map.class, String.class, Object.class);
|
||||
Map<String, Object> headers = resolveArgument(param);
|
||||
|
@ -70,25 +69,25 @@ public class HeadersMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveArgumentAnnotatedNotMap() {
|
||||
void resolveArgumentAnnotatedNotMap() {
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
resolveArgument(this.resolvable.annotPresent(Headers.class).arg(String.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveArgumentMessageHeaders() {
|
||||
void resolveArgumentMessageHeaders() {
|
||||
MessageHeaders headers = resolveArgument(this.resolvable.arg(MessageHeaders.class));
|
||||
assertThat(headers.get("foo")).isEqualTo("bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveArgumentMessageHeaderAccessor() {
|
||||
void resolveArgumentMessageHeaderAccessor() {
|
||||
MessageHeaderAccessor headers = resolveArgument(this.resolvable.arg(MessageHeaderAccessor.class));
|
||||
assertThat(headers.getHeader("foo")).isEqualTo("bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveArgumentMessageHeaderAccessorSubclass() {
|
||||
void resolveArgumentMessageHeaderAccessorSubclass() {
|
||||
TestMessageHeaderAccessor headers = resolveArgument(this.resolvable.arg(TestMessageHeaderAccessor.class));
|
||||
assertThat(headers.getHeader("foo")).isEqualTo("bar");
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -64,56 +64,56 @@ public class MessageMappingMessageHandlerTests {
|
|||
|
||||
|
||||
@Test
|
||||
public void handleString() {
|
||||
void handleString() {
|
||||
MessageMappingMessageHandler messsageHandler = initMesssageHandler();
|
||||
messsageHandler.handleMessage(message("string", "abcdef")).block(Duration.ofSeconds(5));
|
||||
verifyOutputContent(Collections.singletonList("abcdef::response"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleMonoString() {
|
||||
void handleMonoString() {
|
||||
MessageMappingMessageHandler messsageHandler = initMesssageHandler();
|
||||
messsageHandler.handleMessage(message("monoString", "abcdef")).block(Duration.ofSeconds(5));
|
||||
verifyOutputContent(Collections.singletonList("abcdef::response"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleFluxString() {
|
||||
void handleFluxString() {
|
||||
MessageMappingMessageHandler messsageHandler = initMesssageHandler();
|
||||
messsageHandler.handleMessage(message("fluxString", "abc", "def", "ghi")).block(Duration.ofSeconds(5));
|
||||
verifyOutputContent(Arrays.asList("abc::response", "def::response", "ghi::response"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleWithPlaceholderInMapping() {
|
||||
void handleWithPlaceholderInMapping() {
|
||||
MessageMappingMessageHandler messsageHandler = initMesssageHandler();
|
||||
messsageHandler.handleMessage(message("path123", "abcdef")).block(Duration.ofSeconds(5));
|
||||
verifyOutputContent(Collections.singletonList("abcdef::response"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleWithDestinationVariable() {
|
||||
void handleWithDestinationVariable() {
|
||||
MessageMappingMessageHandler messsageHandler = initMesssageHandler();
|
||||
messsageHandler.handleMessage(message("destination.test", "abcdef")).block(Duration.ofSeconds(5));
|
||||
verifyOutputContent(Collections.singletonList("test::abcdef::response"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleException() {
|
||||
void handleException() {
|
||||
MessageMappingMessageHandler messsageHandler = initMesssageHandler();
|
||||
messsageHandler.handleMessage(message("exception", "abc")).block(Duration.ofSeconds(5));
|
||||
verifyOutputContent(Collections.singletonList("rejected::handled"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleErrorSignal() {
|
||||
void handleErrorSignal() {
|
||||
MessageMappingMessageHandler messsageHandler = initMesssageHandler();
|
||||
messsageHandler.handleMessage(message("errorSignal", "abc")).block(Duration.ofSeconds(5));
|
||||
verifyOutputContent(Collections.singletonList("rejected::handled"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unhandledExceptionShouldFlowThrough() {
|
||||
void unhandledExceptionShouldFlowThrough() {
|
||||
|
||||
GenericMessage<?> message = new GenericMessage<>(new Object(),
|
||||
Collections.singletonMap(DestinationPatternsMessageCondition.LOOKUP_DESTINATION_HEADER,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -56,7 +56,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class PayloadMethodArgumentResolverTests {
|
||||
class PayloadMethodArgumentResolverTests {
|
||||
|
||||
private final List<Decoder<?>> decoders = new ArrayList<>();
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class PayloadMethodArgumentResolverTests {
|
|||
|
||||
|
||||
@Test
|
||||
public void supportsParameter() {
|
||||
void supportsParameter() {
|
||||
|
||||
boolean useDefaultResolution = true;
|
||||
PayloadMethodArgumentResolver resolver = createResolver(null, useDefaultResolution);
|
||||
|
@ -80,7 +80,7 @@ public class PayloadMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void emptyBodyWhenRequired() {
|
||||
void emptyBodyWhenRequired() {
|
||||
MethodParameter param = this.testMethod.arg(ResolvableType.forClassWithGenerics(Mono.class, String.class));
|
||||
Mono<Object> mono = resolveValue(param, Mono.empty(), null);
|
||||
|
||||
|
@ -93,13 +93,13 @@ public class PayloadMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void emptyBodyWhenNotRequired() {
|
||||
void emptyBodyWhenNotRequired() {
|
||||
MethodParameter param = this.testMethod.annotPresent(Payload.class).arg();
|
||||
assertThat(this.<Object>resolveValue(param, Mono.empty(), null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stringMono() {
|
||||
void stringMono() {
|
||||
String body = "foo";
|
||||
MethodParameter param = this.testMethod.arg(ResolvableType.forClassWithGenerics(Mono.class, String.class));
|
||||
Mono<Object> mono = resolveValue(param,
|
||||
|
@ -109,7 +109,7 @@ public class PayloadMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void stringFlux() {
|
||||
void stringFlux() {
|
||||
List<String> body = Arrays.asList("foo", "bar");
|
||||
ResolvableType type = ResolvableType.forClassWithGenerics(Flux.class, String.class);
|
||||
MethodParameter param = this.testMethod.arg(type);
|
||||
|
@ -120,7 +120,7 @@ public class PayloadMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void string() {
|
||||
void string() {
|
||||
String body = "foo";
|
||||
MethodParameter param = this.testMethod.annotNotPresent(Payload.class).arg(String.class);
|
||||
Object value = resolveValue(param, Mono.just(toDataBuffer(body)), null);
|
||||
|
@ -129,7 +129,7 @@ public class PayloadMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void validateStringMono() {
|
||||
void validateStringMono() {
|
||||
TestValidator validator = new TestValidator();
|
||||
ResolvableType type = ResolvableType.forClassWithGenerics(Mono.class, String.class);
|
||||
MethodParameter param = this.testMethod.arg(type);
|
||||
|
@ -140,7 +140,7 @@ public class PayloadMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void validateStringFlux() {
|
||||
void validateStringFlux() {
|
||||
TestValidator validator = new TestValidator();
|
||||
ResolvableType type = ResolvableType.forClassWithGenerics(Flux.class, String.class);
|
||||
MethodParameter param = this.testMethod.arg(type);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -36,32 +36,32 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
|||
* @author Rossen Stoyanchev
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class AnnotationExceptionHandlerMethodResolverTests {
|
||||
class AnnotationExceptionHandlerMethodResolverTests {
|
||||
|
||||
private final AnnotationExceptionHandlerMethodResolver resolver =
|
||||
new AnnotationExceptionHandlerMethodResolver(ExceptionController.class);
|
||||
|
||||
|
||||
@Test
|
||||
public void resolveMethodFromAnnotation() {
|
||||
void resolveMethodFromAnnotation() {
|
||||
IOException exception = new IOException();
|
||||
assertThat(this.resolver.resolveMethod(exception).getName()).isEqualTo("handleIOException");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveMethodFromArgument() {
|
||||
void resolveMethodFromArgument() {
|
||||
IllegalArgumentException exception = new IllegalArgumentException();
|
||||
assertThat(this.resolver.resolveMethod(exception).getName()).isEqualTo("handleIllegalArgumentException");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveMethodFromArgumentWithErrorType() {
|
||||
void resolveMethodFromArgumentWithErrorType() {
|
||||
AssertionError exception = new AssertionError();
|
||||
assertThat(this.resolver.resolveMethod(new IllegalStateException(exception)).getName()).isEqualTo("handleAssertionError");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveMethodExceptionSubType() {
|
||||
void resolveMethodExceptionSubType() {
|
||||
IOException ioException = new FileNotFoundException();
|
||||
assertThat(this.resolver.resolveMethod(ioException).getName()).isEqualTo("handleIOException");
|
||||
SocketException bindException = new BindException();
|
||||
|
@ -69,38 +69,38 @@ public class AnnotationExceptionHandlerMethodResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveMethodBestMatch() {
|
||||
void resolveMethodBestMatch() {
|
||||
SocketException exception = new SocketException();
|
||||
assertThat(this.resolver.resolveMethod(exception).getName()).isEqualTo("handleSocketException");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveMethodNoMatch() {
|
||||
void resolveMethodNoMatch() {
|
||||
Exception exception = new Exception();
|
||||
assertThat(this.resolver.resolveMethod(exception)).as("1st lookup").isNull();
|
||||
assertThat(this.resolver.resolveMethod(exception)).as("2nd lookup from cache").isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveMethodInherited() {
|
||||
void resolveMethodInherited() {
|
||||
IOException exception = new IOException();
|
||||
assertThat(this.resolver.resolveMethod(exception).getName()).isEqualTo("handleIOException");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveMethodAgainstCause() {
|
||||
void resolveMethodAgainstCause() {
|
||||
IllegalStateException exception = new IllegalStateException(new IOException());
|
||||
assertThat(this.resolver.resolveMethod(exception).getName()).isEqualTo("handleIOException");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ambiguousExceptionMapping() {
|
||||
void ambiguousExceptionMapping() {
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
new AnnotationExceptionHandlerMethodResolver(AmbiguousController.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noExceptionMapping() {
|
||||
void noExceptionMapping() {
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
new AnnotationExceptionHandlerMethodResolver(NoExceptionController.class));
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -49,13 +49,13 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
|||
/**
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class DefaultMessageHandlerMethodFactoryTests {
|
||||
class DefaultMessageHandlerMethodFactoryTests {
|
||||
|
||||
private final SampleBean sample = new SampleBean();
|
||||
|
||||
|
||||
@Test
|
||||
public void customConversion() throws Exception {
|
||||
void customConversion() throws Exception {
|
||||
DefaultMessageHandlerMethodFactory instance = createInstance();
|
||||
GenericConversionService conversionService = new GenericConversionService();
|
||||
conversionService.addConverter(SampleBean.class, String.class, source -> "foo bar");
|
||||
|
@ -70,7 +70,7 @@ public class DefaultMessageHandlerMethodFactoryTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void customConversionServiceFailure() throws Exception {
|
||||
void customConversionServiceFailure() {
|
||||
DefaultMessageHandlerMethodFactory instance = createInstance();
|
||||
GenericConversionService conversionService = new GenericConversionService();
|
||||
assertThat(conversionService.canConvert(Integer.class, String.class)).as("conversion service should fail to convert payload").isFalse();
|
||||
|
@ -85,7 +85,7 @@ public class DefaultMessageHandlerMethodFactoryTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void customMessageConverterFailure() throws Exception {
|
||||
void customMessageConverterFailure() {
|
||||
DefaultMessageHandlerMethodFactory instance = createInstance();
|
||||
MessageConverter messageConverter = new ByteArrayMessageConverter();
|
||||
instance.setMessageConverter(messageConverter);
|
||||
|
@ -99,7 +99,7 @@ public class DefaultMessageHandlerMethodFactoryTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void customArgumentResolver() throws Exception {
|
||||
void customArgumentResolver() throws Exception {
|
||||
DefaultMessageHandlerMethodFactory instance = createInstance();
|
||||
List<HandlerMethodArgumentResolver> customResolvers = new ArrayList<>();
|
||||
customResolvers.add(new CustomHandlerMethodArgumentResolver());
|
||||
|
@ -114,7 +114,7 @@ public class DefaultMessageHandlerMethodFactoryTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void overrideArgumentResolvers() throws Exception {
|
||||
void overrideArgumentResolvers() throws Exception {
|
||||
DefaultMessageHandlerMethodFactory instance = createInstance();
|
||||
List<HandlerMethodArgumentResolver> customResolvers = new ArrayList<>();
|
||||
customResolvers.add(new CustomHandlerMethodArgumentResolver());
|
||||
|
@ -138,7 +138,7 @@ public class DefaultMessageHandlerMethodFactoryTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void noValidationByDefault() throws Exception {
|
||||
void noValidationByDefault() throws Exception {
|
||||
DefaultMessageHandlerMethodFactory instance = createInstance();
|
||||
instance.afterPropertiesSet();
|
||||
|
||||
|
@ -149,7 +149,7 @@ public class DefaultMessageHandlerMethodFactoryTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void customValidation() throws Exception {
|
||||
void customValidation() {
|
||||
DefaultMessageHandlerMethodFactory instance = createInstance();
|
||||
instance.setValidator(new Validator() {
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -38,7 +38,7 @@ import static org.springframework.messaging.handler.annotation.MessagingPredicat
|
|||
*
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
public class DestinationVariableMethodArgumentResolverTests {
|
||||
class DestinationVariableMethodArgumentResolverTests {
|
||||
|
||||
private final DestinationVariableMethodArgumentResolver resolver =
|
||||
new DestinationVariableMethodArgumentResolver(new DefaultConversionService());
|
||||
|
@ -48,13 +48,13 @@ public class DestinationVariableMethodArgumentResolverTests {
|
|||
|
||||
|
||||
@Test
|
||||
public void supportsParameter() {
|
||||
void supportsParameter() {
|
||||
assertThat(resolver.supportsParameter(this.resolvable.annot(destinationVar().noValue()).arg())).isTrue();
|
||||
assertThat(resolver.supportsParameter(this.resolvable.annotNotPresent(DestinationVariable.class).arg())).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveArgument() throws Exception {
|
||||
void resolveArgument() throws Exception {
|
||||
|
||||
Map<String, Object> vars = new HashMap<>();
|
||||
vars.put("foo", "bar");
|
||||
|
@ -73,7 +73,7 @@ public class DestinationVariableMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveArgumentNotFound() throws Exception {
|
||||
void resolveArgumentNotFound() {
|
||||
Message<byte[]> message = MessageBuilder.withPayload(new byte[0]).build();
|
||||
assertThatExceptionOfType(MessageHandlingException.class).isThrownBy(() ->
|
||||
this.resolver.resolveArgument(this.resolvable.annot(destinationVar().noValue()).arg(), message));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -45,7 +45,7 @@ import static org.springframework.messaging.handler.annotation.MessagingPredicat
|
|||
* @author Juergen Hoeller
|
||||
* @since 4.0
|
||||
*/
|
||||
public class HeaderMethodArgumentResolverTests {
|
||||
class HeaderMethodArgumentResolverTests {
|
||||
|
||||
private HeaderMethodArgumentResolver resolver;
|
||||
|
||||
|
@ -53,7 +53,6 @@ public class HeaderMethodArgumentResolverTests {
|
|||
|
||||
|
||||
@BeforeEach
|
||||
@SuppressWarnings("resource")
|
||||
public void setup() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
context.refresh();
|
||||
|
@ -62,13 +61,13 @@ public class HeaderMethodArgumentResolverTests {
|
|||
|
||||
|
||||
@Test
|
||||
public void supportsParameter() {
|
||||
void supportsParameter() {
|
||||
assertThat(this.resolver.supportsParameter(this.resolvable.annot(headerPlain()).arg())).isTrue();
|
||||
assertThat(this.resolver.supportsParameter(this.resolvable.annotNotPresent(Header.class).arg())).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveArgument() throws Exception {
|
||||
void resolveArgument() throws Exception {
|
||||
Message<byte[]> message = MessageBuilder.withPayload(new byte[0]).setHeader("param1", "foo").build();
|
||||
Object result = this.resolver.resolveArgument(this.resolvable.annot(headerPlain()).arg(), message);
|
||||
assertThat(result).isEqualTo("foo");
|
||||
|
@ -83,7 +82,7 @@ public class HeaderMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveArgumentNativeHeaderAmbiguity() throws Exception {
|
||||
void resolveArgumentNativeHeaderAmbiguity() throws Exception {
|
||||
TestMessageHeaderAccessor headers = new TestMessageHeaderAccessor();
|
||||
headers.setHeader("param1", "foo");
|
||||
headers.setNativeHeader("param1", "native-foo");
|
||||
|
@ -97,21 +96,21 @@ public class HeaderMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveArgumentNotFound() throws Exception {
|
||||
void resolveArgumentNotFound() {
|
||||
Message<byte[]> message = MessageBuilder.withPayload(new byte[0]).build();
|
||||
assertThatExceptionOfType(MessageHandlingException.class).isThrownBy(() ->
|
||||
this.resolver.resolveArgument(this.resolvable.annot(headerPlain()).arg(), message));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveArgumentDefaultValue() throws Exception {
|
||||
void resolveArgumentDefaultValue() throws Exception {
|
||||
Message<byte[]> message = MessageBuilder.withPayload(new byte[0]).build();
|
||||
Object result = this.resolver.resolveArgument(this.resolvable.annot(header("name", "bar")).arg(), message);
|
||||
assertThat(result).isEqualTo("bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveDefaultValueSystemProperty() throws Exception {
|
||||
void resolveDefaultValueSystemProperty() throws Exception {
|
||||
System.setProperty("systemProperty", "sysbar");
|
||||
try {
|
||||
Message<byte[]> message = MessageBuilder.withPayload(new byte[0]).build();
|
||||
|
@ -125,7 +124,7 @@ public class HeaderMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveNameFromSystemProperty() throws Exception {
|
||||
void resolveNameFromSystemProperty() throws Exception {
|
||||
System.setProperty("systemProperty", "sysbar");
|
||||
try {
|
||||
Message<byte[]> message = MessageBuilder.withPayload(new byte[0]).setHeader("sysbar", "foo").build();
|
||||
|
@ -139,7 +138,7 @@ public class HeaderMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveOptionalHeaderWithValue() throws Exception {
|
||||
void resolveOptionalHeaderWithValue() throws Exception {
|
||||
Message<String> message = MessageBuilder.withPayload("foo").setHeader("foo", "bar").build();
|
||||
MethodParameter param = this.resolvable.annot(header("foo")).arg(Optional.class, String.class);
|
||||
Object result = resolver.resolveArgument(param, message);
|
||||
|
@ -147,7 +146,7 @@ public class HeaderMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveOptionalHeaderAsEmpty() throws Exception {
|
||||
void resolveOptionalHeaderAsEmpty() throws Exception {
|
||||
Message<String> message = MessageBuilder.withPayload("foo").build();
|
||||
MethodParameter param = this.resolvable.annot(header("foo")).arg(Optional.class, String.class);
|
||||
Object result = resolver.resolveArgument(param, message);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
|||
* @author Rossen Stoyanchev
|
||||
* @since 4.0
|
||||
*/
|
||||
public class HeadersMethodArgumentResolverTests {
|
||||
class HeadersMethodArgumentResolverTests {
|
||||
|
||||
private final HeadersMethodArgumentResolver resolver = new HeadersMethodArgumentResolver();
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class HeadersMethodArgumentResolverTests {
|
|||
|
||||
|
||||
@Test
|
||||
public void supportsParameter() {
|
||||
void supportsParameter() {
|
||||
|
||||
assertThat(this.resolver.supportsParameter(
|
||||
this.resolvable.annotPresent(Headers.class).arg(Map.class, String.class, Object.class))).isTrue();
|
||||
|
@ -63,7 +63,7 @@ public class HeadersMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveArgumentAnnotated() throws Exception {
|
||||
void resolveArgumentAnnotated() throws Exception {
|
||||
MethodParameter param = this.resolvable.annotPresent(Headers.class).arg(Map.class, String.class, Object.class);
|
||||
Object resolved = this.resolver.resolveArgument(param, this.message);
|
||||
|
||||
|
@ -75,13 +75,13 @@ public class HeadersMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveArgumentAnnotatedNotMap() throws Exception {
|
||||
void resolveArgumentAnnotatedNotMap() {
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
this.resolver.resolveArgument(this.resolvable.annotPresent(Headers.class).arg(String.class), this.message));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveArgumentMessageHeaders() throws Exception {
|
||||
void resolveArgumentMessageHeaders() throws Exception {
|
||||
Object resolved = this.resolver.resolveArgument(this.resolvable.arg(MessageHeaders.class), this.message);
|
||||
|
||||
boolean condition = resolved instanceof MessageHeaders;
|
||||
|
@ -91,7 +91,7 @@ public class HeadersMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveArgumentMessageHeaderAccessor() throws Exception {
|
||||
void resolveArgumentMessageHeaderAccessor() throws Exception {
|
||||
MethodParameter param = this.resolvable.arg(MessageHeaderAccessor.class);
|
||||
Object resolved = this.resolver.resolveArgument(param, this.message);
|
||||
|
||||
|
@ -102,7 +102,7 @@ public class HeadersMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveArgumentMessageHeaderAccessorSubclass() throws Exception {
|
||||
void resolveArgumentMessageHeaderAccessorSubclass() throws Exception {
|
||||
MethodParameter param = this.resolvable.arg(TestMessageHeaderAccessor.class);
|
||||
Object resolved = this.resolver.resolveArgument(param, this.message);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -42,7 +42,7 @@ import static org.mockito.Mockito.mock;
|
|||
* @author Stephane Nicoll
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class MessageMethodArgumentResolverTests {
|
||||
class MessageMethodArgumentResolverTests {
|
||||
|
||||
private MessageConverter converter = mock();
|
||||
|
||||
|
@ -52,14 +52,14 @@ public class MessageMethodArgumentResolverTests {
|
|||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
void setup() throws Exception {
|
||||
this.method = getClass().getDeclaredMethod("handle",
|
||||
Message.class, Message.class, Message.class, Message.class, ErrorMessage.class, Message.class);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void resolveWithPayloadTypeAsWildcard() throws Exception {
|
||||
void resolveWithPayloadTypeAsWildcard() throws Exception {
|
||||
Message<String> message = MessageBuilder.withPayload("test").build();
|
||||
MethodParameter parameter = new MethodParameter(this.method, 0);
|
||||
|
||||
|
@ -68,7 +68,7 @@ public class MessageMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveWithMatchingPayloadType() throws Exception {
|
||||
void resolveWithMatchingPayloadType() throws Exception {
|
||||
Message<Integer> message = MessageBuilder.withPayload(123).build();
|
||||
MethodParameter parameter = new MethodParameter(this.method, 1);
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class MessageMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveWithPayloadTypeSubclass() throws Exception {
|
||||
void resolveWithPayloadTypeSubclass() throws Exception {
|
||||
Message<Integer> message = MessageBuilder.withPayload(123).build();
|
||||
MethodParameter parameter = new MethodParameter(this.method, 2);
|
||||
|
||||
|
@ -86,7 +86,7 @@ public class MessageMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveWithConversion() throws Exception {
|
||||
void resolveWithConversion() throws Exception {
|
||||
Message<String> message = MessageBuilder.withPayload("test").build();
|
||||
MethodParameter parameter = new MethodParameter(this.method, 1);
|
||||
|
||||
|
@ -101,7 +101,7 @@ public class MessageMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveWithConversionNoMatchingConverter() throws Exception {
|
||||
void resolveWithConversionNoMatchingConverter() {
|
||||
Message<String> message = MessageBuilder.withPayload("test").build();
|
||||
MethodParameter parameter = new MethodParameter(this.method, 1);
|
||||
|
||||
|
@ -113,7 +113,7 @@ public class MessageMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveWithConversionEmptyPayload() throws Exception {
|
||||
void resolveWithConversionEmptyPayload() {
|
||||
Message<String> message = MessageBuilder.withPayload("").build();
|
||||
MethodParameter parameter = new MethodParameter(this.method, 1);
|
||||
|
||||
|
@ -126,7 +126,7 @@ public class MessageMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveWithPayloadTypeUpperBound() throws Exception {
|
||||
void resolveWithPayloadTypeUpperBound() throws Exception {
|
||||
Message<Integer> message = MessageBuilder.withPayload(123).build();
|
||||
MethodParameter parameter = new MethodParameter(this.method, 3);
|
||||
|
||||
|
@ -135,7 +135,7 @@ public class MessageMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveWithPayloadTypeOutOfBound() throws Exception {
|
||||
void resolveWithPayloadTypeOutOfBound() {
|
||||
Message<Locale> message = MessageBuilder.withPayload(Locale.getDefault()).build();
|
||||
MethodParameter parameter = new MethodParameter(this.method, 3);
|
||||
|
||||
|
@ -147,7 +147,7 @@ public class MessageMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveMessageSubclassMatch() throws Exception {
|
||||
void resolveMessageSubclassMatch() throws Exception {
|
||||
ErrorMessage message = new ErrorMessage(new UnsupportedOperationException());
|
||||
MethodParameter parameter = new MethodParameter(this.method, 4);
|
||||
|
||||
|
@ -156,7 +156,7 @@ public class MessageMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveWithMessageSubclassAndPayloadWildcard() throws Exception {
|
||||
void resolveWithMessageSubclassAndPayloadWildcard() throws Exception {
|
||||
ErrorMessage message = new ErrorMessage(new UnsupportedOperationException());
|
||||
MethodParameter parameter = new MethodParameter(this.method, 0);
|
||||
|
||||
|
@ -165,7 +165,7 @@ public class MessageMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveWithWrongMessageType() throws Exception {
|
||||
void resolveWithWrongMessageType() {
|
||||
UnsupportedOperationException ex = new UnsupportedOperationException();
|
||||
Message<? extends Throwable> message = new GenericMessage<Throwable>(ex);
|
||||
MethodParameter parameter = new MethodParameter(this.method, 4);
|
||||
|
@ -178,7 +178,7 @@ public class MessageMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveWithPayloadTypeAsWildcardAndNoConverter() throws Exception {
|
||||
void resolveWithPayloadTypeAsWildcardAndNoConverter() throws Exception {
|
||||
this.resolver = new MessageMethodArgumentResolver();
|
||||
|
||||
Message<String> message = MessageBuilder.withPayload("test").build();
|
||||
|
@ -189,7 +189,7 @@ public class MessageMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveWithConversionNeededButNoConverter() throws Exception {
|
||||
void resolveWithConversionNeededButNoConverter() {
|
||||
this.resolver = new MessageMethodArgumentResolver();
|
||||
|
||||
Message<String> message = MessageBuilder.withPayload("test").build();
|
||||
|
@ -203,7 +203,7 @@ public class MessageMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveWithConversionEmptyPayloadButNoConverter() throws Exception {
|
||||
void resolveWithConversionEmptyPayloadButNoConverter() {
|
||||
this.resolver = new MessageMethodArgumentResolver();
|
||||
|
||||
Message<String> message = MessageBuilder.withPayload("").build();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -50,7 +50,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
|||
* @author Brian Clozel
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class PayloadMethodArgumentResolverTests {
|
||||
class PayloadMethodArgumentResolverTests {
|
||||
|
||||
private PayloadMethodArgumentResolver resolver;
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class PayloadMethodArgumentResolverTests {
|
|||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
void setup() throws Exception {
|
||||
this.resolver = new PayloadMethodArgumentResolver(new StringMessageConverter(), testValidator());
|
||||
|
||||
Method payloadMethod = PayloadMethodArgumentResolverTests.class.getDeclaredMethod(
|
||||
|
@ -91,7 +91,7 @@ public class PayloadMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void supportsParameter() {
|
||||
void supportsParameter() {
|
||||
assertThat(this.resolver.supportsParameter(this.paramAnnotated)).isTrue();
|
||||
assertThat(this.resolver.supportsParameter(this.paramNotAnnotated)).isTrue();
|
||||
|
||||
|
@ -103,7 +103,7 @@ public class PayloadMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveRequired() throws Exception {
|
||||
void resolveRequired() throws Exception {
|
||||
Message<?> message = MessageBuilder.withPayload("ABC".getBytes()).build();
|
||||
Object actual = this.resolver.resolveArgument(paramAnnotated, message);
|
||||
|
||||
|
@ -111,7 +111,7 @@ public class PayloadMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveRequiredEmpty() {
|
||||
void resolveRequiredEmpty() {
|
||||
Message<?> message = MessageBuilder.withPayload("").build();
|
||||
// required but empty
|
||||
assertThatExceptionOfType(MethodArgumentNotValidException.class)
|
||||
|
@ -119,7 +119,7 @@ public class PayloadMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveRequiredEmptyNonAnnotatedParameter() {
|
||||
void resolveRequiredEmptyNonAnnotatedParameter() {
|
||||
Message<?> message = MessageBuilder.withPayload("").build();
|
||||
// required but empty
|
||||
assertThatExceptionOfType(MethodArgumentNotValidException.class)
|
||||
|
@ -127,7 +127,7 @@ public class PayloadMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveNotRequired() throws Exception {
|
||||
void resolveNotRequired() throws Exception {
|
||||
Message<?> emptyByteArrayMessage = MessageBuilder.withPayload(new byte[0]).build();
|
||||
assertThat(this.resolver.resolveArgument(this.paramAnnotatedNotRequired, emptyByteArrayMessage)).isNull();
|
||||
|
||||
|
@ -143,7 +143,7 @@ public class PayloadMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveOptionalTarget() throws Exception {
|
||||
void resolveOptionalTarget() throws Exception {
|
||||
Message<?> message = MessageBuilder.withPayload("ABC".getBytes()).build();
|
||||
Object actual = this.resolver.resolveArgument(paramOptional, message);
|
||||
|
||||
|
@ -151,7 +151,7 @@ public class PayloadMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveOptionalSource() throws Exception {
|
||||
void resolveOptionalSource() throws Exception {
|
||||
Message<?> message = MessageBuilder.withPayload(Optional.of("ABC".getBytes())).build();
|
||||
Object actual = this.resolver.resolveArgument(paramAnnotated, message);
|
||||
|
||||
|
@ -159,7 +159,7 @@ public class PayloadMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveNonConvertibleParam() {
|
||||
void resolveNonConvertibleParam() {
|
||||
Message<?> notEmptyMessage = MessageBuilder.withPayload(123).build();
|
||||
|
||||
assertThatExceptionOfType(MessageConversionException.class)
|
||||
|
@ -168,7 +168,7 @@ public class PayloadMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveSpelExpressionNotSupported() {
|
||||
void resolveSpelExpressionNotSupported() {
|
||||
Message<?> message = MessageBuilder.withPayload("ABC".getBytes()).build();
|
||||
|
||||
assertThatIllegalStateException()
|
||||
|
@ -176,13 +176,13 @@ public class PayloadMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveValidation() throws Exception {
|
||||
void resolveValidation() throws Exception {
|
||||
Message<?> message = MessageBuilder.withPayload("ABC".getBytes()).build();
|
||||
this.resolver.resolveArgument(this.paramValidated, message);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveFailValidation() {
|
||||
void resolveFailValidation() {
|
||||
// See testValidator()
|
||||
Message<?> message = MessageBuilder.withPayload("invalidValue".getBytes()).build();
|
||||
|
||||
|
@ -191,7 +191,7 @@ public class PayloadMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveFailValidationNoConversionNecessary() {
|
||||
void resolveFailValidationNoConversionNecessary() {
|
||||
Message<?> message = MessageBuilder.withPayload("invalidValue").build();
|
||||
|
||||
assertThatExceptionOfType(MethodArgumentNotValidException.class)
|
||||
|
@ -199,7 +199,7 @@ public class PayloadMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveNonAnnotatedParameter() throws Exception {
|
||||
void resolveNonAnnotatedParameter() throws Exception {
|
||||
Message<?> notEmptyMessage = MessageBuilder.withPayload("ABC".getBytes()).build();
|
||||
assertThat(this.resolver.resolveArgument(this.paramNotAnnotated, notEmptyMessage)).isEqualTo("ABC");
|
||||
|
||||
|
@ -209,7 +209,7 @@ public class PayloadMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveNonAnnotatedParameterFailValidation() {
|
||||
void resolveNonAnnotatedParameterFailValidation() {
|
||||
// See testValidator()
|
||||
Message<?> message = MessageBuilder.withPayload("invalidValue".getBytes()).build();
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -37,7 +37,7 @@ import static org.mockito.Mockito.mock;
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class InvocableHandlerMethodTests {
|
||||
class InvocableHandlerMethodTests {
|
||||
|
||||
private final Message<?> message = mock();
|
||||
|
||||
|
@ -45,7 +45,7 @@ public class InvocableHandlerMethodTests {
|
|||
|
||||
|
||||
@Test
|
||||
public void resolveArg() throws Exception {
|
||||
void resolveArg() throws Exception {
|
||||
this.resolvers.addResolver(new StubArgumentResolver(99));
|
||||
this.resolvers.addResolver(new StubArgumentResolver("value"));
|
||||
Method method = ResolvableMethod.on(Handler.class).mockCall(c -> c.handle(0, "")).method();
|
||||
|
@ -59,7 +59,7 @@ public class InvocableHandlerMethodTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveNoArgValue() throws Exception {
|
||||
void resolveNoArgValue() throws Exception {
|
||||
this.resolvers.addResolver(new StubArgumentResolver(Integer.class));
|
||||
this.resolvers.addResolver(new StubArgumentResolver(String.class));
|
||||
Method method = ResolvableMethod.on(Handler.class).mockCall(c -> c.handle(0, "")).method();
|
||||
|
@ -71,7 +71,7 @@ public class InvocableHandlerMethodTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void cannotResolveArg() throws Exception {
|
||||
void cannotResolveArg() {
|
||||
Method method = ResolvableMethod.on(Handler.class).mockCall(c -> c.handle(0, "")).method();
|
||||
assertThatExceptionOfType(MethodArgumentResolutionException.class)
|
||||
.isThrownBy(() -> invoke(new Handler(), method))
|
||||
|
@ -79,7 +79,7 @@ public class InvocableHandlerMethodTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveProvidedArg() throws Exception {
|
||||
void resolveProvidedArg() throws Exception {
|
||||
Method method = ResolvableMethod.on(Handler.class).mockCall(c -> c.handle(0, "")).method();
|
||||
Object value = invoke(new Handler(), method, 99, "value");
|
||||
|
||||
|
@ -89,7 +89,7 @@ public class InvocableHandlerMethodTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveProvidedArgFirst() throws Exception {
|
||||
void resolveProvidedArgFirst() throws Exception {
|
||||
this.resolvers.addResolver(new StubArgumentResolver(1));
|
||||
this.resolvers.addResolver(new StubArgumentResolver("value1"));
|
||||
Method method = ResolvableMethod.on(Handler.class).mockCall(c -> c.handle(0, "")).method();
|
||||
|
@ -99,7 +99,7 @@ public class InvocableHandlerMethodTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void exceptionInResolvingArg() throws Exception {
|
||||
void exceptionInResolvingArg() {
|
||||
this.resolvers.addResolver(new ExceptionRaisingArgumentResolver());
|
||||
Method method = ResolvableMethod.on(Handler.class).mockCall(c -> c.handle(0, "")).method();
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
|
@ -108,7 +108,7 @@ public class InvocableHandlerMethodTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void illegalArgumentException() throws Exception {
|
||||
void illegalArgumentException() {
|
||||
this.resolvers.addResolver(new StubArgumentResolver(Integer.class, "__not_an_int__"));
|
||||
this.resolvers.addResolver(new StubArgumentResolver("value"));
|
||||
Method method = ResolvableMethod.on(Handler.class).mockCall(c -> c.handle(0, "")).method();
|
||||
|
@ -123,7 +123,7 @@ public class InvocableHandlerMethodTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void invocationTargetException() throws Exception {
|
||||
void invocationTargetException() {
|
||||
Handler handler = new Handler();
|
||||
Method method = ResolvableMethod.on(Handler.class).argTypes(Throwable.class).resolveMethod();
|
||||
RuntimeException runtimeException = new RuntimeException("error");
|
||||
|
@ -146,7 +146,7 @@ public class InvocableHandlerMethodTests {
|
|||
}
|
||||
|
||||
@Test // Based on SPR-13917 (spring-web)
|
||||
public void invocationErrorMessage() throws Exception {
|
||||
public void invocationErrorMessage() {
|
||||
this.resolvers.addResolver(new StubArgumentResolver(double.class));
|
||||
Method method = ResolvableMethod.on(Handler.class).mockCall(c -> c.handle(0.0)).method();
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -18,7 +18,6 @@ package org.springframework.messaging.handler.invocation;
|
|||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
|
@ -50,7 +49,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
|||
* @author Brian Clozel
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class MethodMessageHandlerTests {
|
||||
class MethodMessageHandlerTests {
|
||||
|
||||
private static final String DESTINATION_HEADER = "destination";
|
||||
|
||||
|
@ -60,9 +59,9 @@ public class MethodMessageHandlerTests {
|
|||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
void setup() {
|
||||
|
||||
List<String> destinationPrefixes = Arrays.asList("/test");
|
||||
List<String> destinationPrefixes = List.of("/test");
|
||||
|
||||
this.messageHandler = new TestMethodMessageHandler();
|
||||
this.messageHandler.setApplicationContext(new StaticApplicationContext());
|
||||
|
@ -74,13 +73,13 @@ public class MethodMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void duplicateMapping() {
|
||||
void duplicateMapping() {
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
this.messageHandler.registerHandler(new DuplicateMappingsController()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void registeredMappings() {
|
||||
void registeredMappings() {
|
||||
|
||||
Map<String, HandlerMethod> handlerMethods = this.messageHandler.getHandlerMethods();
|
||||
|
||||
|
@ -89,7 +88,7 @@ public class MethodMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void patternMatch() throws Exception {
|
||||
void patternMatch() throws Exception {
|
||||
|
||||
Method method = this.testController.getClass().getMethod("handlerPathMatchWildcard");
|
||||
this.messageHandler.registerHandlerMethod(this.testController, method, "/handlerPathMatch*");
|
||||
|
@ -100,7 +99,7 @@ public class MethodMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void bestMatch() throws Exception {
|
||||
void bestMatch() throws Exception {
|
||||
|
||||
Method method = this.testController.getClass().getMethod("bestMatch");
|
||||
this.messageHandler.registerHandlerMethod(this.testController, method, "/bestmatch/{foo}/path");
|
||||
|
@ -114,7 +113,7 @@ public class MethodMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void argumentResolution() {
|
||||
void argumentResolution() {
|
||||
|
||||
this.messageHandler.handleMessage(toDestination("/test/handlerArgumentResolver"));
|
||||
|
||||
|
@ -123,7 +122,7 @@ public class MethodMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void handleException() {
|
||||
void handleException() {
|
||||
|
||||
this.messageHandler.handleMessage(toDestination("/test/handlerThrowsExc"));
|
||||
|
||||
|
@ -205,8 +204,7 @@ public class MethodMessageHandlerTests {
|
|||
|
||||
@Override
|
||||
protected List<? extends HandlerMethodReturnValueHandler> initReturnValueHandlers() {
|
||||
List<HandlerMethodReturnValueHandler> handlers = new ArrayList<>(getCustomReturnValueHandlers());
|
||||
return handlers;
|
||||
return new ArrayList<>(getCustomReturnValueHandlers());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -38,7 +38,7 @@ import static org.springframework.messaging.handler.invocation.ResolvableMethod.
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class EncoderMethodReturnValueHandlerTests {
|
||||
class EncoderMethodReturnValueHandlerTests {
|
||||
|
||||
private final TestEncoderMethodReturnValueHandler handler = new TestEncoderMethodReturnValueHandler(
|
||||
Collections.singletonList(CharSequenceEncoder.textPlainOnly()),
|
||||
|
@ -48,7 +48,7 @@ public class EncoderMethodReturnValueHandlerTests {
|
|||
|
||||
|
||||
@Test
|
||||
public void stringReturnValue() {
|
||||
void stringReturnValue() {
|
||||
MethodParameter parameter = on(TestController.class).resolveReturnType(String.class);
|
||||
this.handler.handleReturnValue("foo", parameter, this.message).block();
|
||||
Flux<String> result = this.handler.getContentAsStrings();
|
||||
|
@ -57,7 +57,7 @@ public class EncoderMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void objectReturnValue() {
|
||||
void objectReturnValue() {
|
||||
MethodParameter parameter = on(TestController.class).resolveReturnType(Object.class);
|
||||
this.handler.handleReturnValue("foo", parameter, this.message).block();
|
||||
Flux<String> result = this.handler.getContentAsStrings();
|
||||
|
@ -66,7 +66,7 @@ public class EncoderMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fluxStringReturnValue() {
|
||||
void fluxStringReturnValue() {
|
||||
MethodParameter parameter = on(TestController.class).resolveReturnType(Flux.class, String.class);
|
||||
this.handler.handleReturnValue(Flux.just("foo", "bar"), parameter, this.message).block();
|
||||
Flux<String> result = this.handler.getContentAsStrings();
|
||||
|
@ -75,7 +75,7 @@ public class EncoderMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fluxObjectReturnValue() {
|
||||
void fluxObjectReturnValue() {
|
||||
MethodParameter parameter = on(TestController.class).resolveReturnType(Flux.class, Object.class);
|
||||
this.handler.handleReturnValue(Flux.just("foo", "bar"), parameter, this.message).block();
|
||||
Flux<String> result = this.handler.getContentAsStrings();
|
||||
|
@ -84,7 +84,7 @@ public class EncoderMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void voidReturnValue() {
|
||||
void voidReturnValue() {
|
||||
testVoidReturnType(null, on(TestController.class).resolveReturnType(void.class));
|
||||
testVoidReturnType(Mono.empty(), on(TestController.class).resolveReturnType(Mono.class, Void.class));
|
||||
testVoidReturnType(Completable.complete(), on(TestController.class).resolveReturnType(Completable.class));
|
||||
|
@ -97,7 +97,7 @@ public class EncoderMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void noEncoder() {
|
||||
void noEncoder() {
|
||||
MethodParameter parameter = on(TestController.class).resolveReturnType(Object.class);
|
||||
StepVerifier.create(this.handler.handleReturnValue(new Object(), parameter, this.message))
|
||||
.expectErrorMessage("No encoder for java.lang.Object, current value type is class java.lang.Object")
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -44,7 +44,7 @@ import static org.mockito.Mockito.mock;
|
|||
* @author Rossen Stoyanchev
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class InvocableHandlerMethodTests {
|
||||
class InvocableHandlerMethodTests {
|
||||
|
||||
private final Message<?> message = mock();
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class InvocableHandlerMethodTests {
|
|||
|
||||
|
||||
@Test
|
||||
public void resolveArg() {
|
||||
void resolveArg() {
|
||||
this.resolvers.add(new StubArgumentResolver(99));
|
||||
this.resolvers.add(new StubArgumentResolver("value"));
|
||||
Method method = ResolvableMethod.on(Handler.class).mockCall(c -> c.handle(0, "")).method();
|
||||
|
@ -66,7 +66,7 @@ public class InvocableHandlerMethodTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveNoArgValue() {
|
||||
void resolveNoArgValue() {
|
||||
this.resolvers.add(new StubArgumentResolver(Integer.class));
|
||||
this.resolvers.add(new StubArgumentResolver(String.class));
|
||||
Method method = ResolvableMethod.on(Handler.class).mockCall(c -> c.handle(0, "")).method();
|
||||
|
@ -78,7 +78,7 @@ public class InvocableHandlerMethodTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void cannotResolveArg() {
|
||||
void cannotResolveArg() {
|
||||
Method method = ResolvableMethod.on(Handler.class).mockCall(c -> c.handle(0, "")).method();
|
||||
assertThatExceptionOfType(MethodArgumentResolutionException.class).isThrownBy(() ->
|
||||
invokeAndBlock(new Handler(), method))
|
||||
|
@ -86,7 +86,7 @@ public class InvocableHandlerMethodTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveProvidedArg() {
|
||||
void resolveProvidedArg() {
|
||||
Method method = ResolvableMethod.on(Handler.class).mockCall(c -> c.handle(0, "")).method();
|
||||
Object value = invokeAndBlock(new Handler(), method, 99, "value");
|
||||
|
||||
|
@ -96,7 +96,7 @@ public class InvocableHandlerMethodTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveProvidedArgFirst() {
|
||||
void resolveProvidedArgFirst() {
|
||||
this.resolvers.add(new StubArgumentResolver(1));
|
||||
this.resolvers.add(new StubArgumentResolver("value1"));
|
||||
Method method = ResolvableMethod.on(Handler.class).mockCall(c -> c.handle(0, "")).method();
|
||||
|
@ -106,7 +106,7 @@ public class InvocableHandlerMethodTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void exceptionInResolvingArg() {
|
||||
void exceptionInResolvingArg() {
|
||||
this.resolvers.add(new InvocableHandlerMethodTests.ExceptionRaisingArgumentResolver());
|
||||
Method method = ResolvableMethod.on(Handler.class).mockCall(c -> c.handle(0, "")).method();
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
|
@ -114,7 +114,7 @@ public class InvocableHandlerMethodTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void illegalArgumentException() {
|
||||
void illegalArgumentException() {
|
||||
this.resolvers.add(new StubArgumentResolver(Integer.class, "__not_an_int__"));
|
||||
this.resolvers.add(new StubArgumentResolver("value"));
|
||||
Method method = ResolvableMethod.on(Handler.class).mockCall(c -> c.handle(0, "")).method();
|
||||
|
@ -129,7 +129,7 @@ public class InvocableHandlerMethodTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void invocationTargetException() {
|
||||
void invocationTargetException() {
|
||||
Method method = ResolvableMethod.on(Handler.class).argTypes(Throwable.class).resolveMethod();
|
||||
|
||||
Throwable expected = new Throwable("error");
|
||||
|
@ -138,7 +138,7 @@ public class InvocableHandlerMethodTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void voidMethod() {
|
||||
void voidMethod() {
|
||||
this.resolvers.add(new StubArgumentResolver(double.class, 5.25));
|
||||
Method method = ResolvableMethod.on(Handler.class).mockCall(c -> c.handle(0.0d)).method();
|
||||
Handler handler = new Handler();
|
||||
|
@ -151,7 +151,7 @@ public class InvocableHandlerMethodTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void voidMonoMethod() {
|
||||
void voidMonoMethod() {
|
||||
Method method = ResolvableMethod.on(Handler.class).mockCall(Handler::handleAsync).method();
|
||||
Handler handler = new Handler();
|
||||
Object value = invokeAndBlock(handler, method);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -52,17 +52,17 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
|||
* Unit tests for {@link AbstractMethodMessageHandler}.
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class MethodMessageHandlerTests {
|
||||
class MethodMessageHandlerTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void duplicateMapping() {
|
||||
void duplicateMapping() {
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
initMethodMessageHandler(DuplicateMappingsController.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void registeredMappings() {
|
||||
void registeredMappings() {
|
||||
TestMethodMessageHandler messageHandler = initMethodMessageHandler(TestController.class);
|
||||
Map<String, HandlerMethod> mappings = messageHandler.getHandlerMethods();
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -53,7 +53,7 @@ import static org.springframework.util.MimeTypeUtils.TEXT_XML;
|
|||
*/
|
||||
class DefaultMetadataExtractorTests {
|
||||
|
||||
private static MimeType COMPOSITE_METADATA =
|
||||
private static final MimeType COMPOSITE_METADATA =
|
||||
MimeTypeUtils.parseMimeType(WellKnownMimeType.MESSAGE_RSOCKET_COMPOSITE_METADATA.getString());
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -64,7 +64,7 @@ import static org.mockito.Mockito.verify;
|
|||
*
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
public class DefaultRSocketRequesterBuilderTests {
|
||||
class DefaultRSocketRequesterBuilderTests {
|
||||
|
||||
private ClientTransport transport = mock();
|
||||
|
||||
|
@ -74,14 +74,13 @@ public class DefaultRSocketRequesterBuilderTests {
|
|||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
void setup() {
|
||||
given(this.transport.connect()).willReturn(Mono.just(this.connection));
|
||||
given(this.transport.maxFrameLength()).willReturn(16777215);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void rsocketConnectorConfigurer() {
|
||||
Consumer<RSocketStrategies.Builder> strategiesConfigurer = mock();
|
||||
RSocketRequester.builder()
|
||||
|
@ -96,7 +95,7 @@ public class DefaultRSocketRequesterBuilderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void defaultDataMimeType() {
|
||||
void defaultDataMimeType() {
|
||||
RSocketRequester requester = RSocketRequester.builder().transport(this.transport);
|
||||
|
||||
assertThat(requester.dataMimeType())
|
||||
|
@ -105,7 +104,7 @@ public class DefaultRSocketRequesterBuilderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void defaultDataMimeTypeWithCustomDecoderRegistered() {
|
||||
void defaultDataMimeTypeWithCustomDecoderRegistered() {
|
||||
RSocketStrategies strategies = RSocketStrategies.builder()
|
||||
.decoder(new TestJsonDecoder(MimeTypeUtils.APPLICATION_JSON))
|
||||
.build();
|
||||
|
@ -120,7 +119,7 @@ public class DefaultRSocketRequesterBuilderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void dataMimeTypeExplicitlySet() {
|
||||
void dataMimeTypeExplicitlySet() {
|
||||
RSocketRequester requester = RSocketRequester.builder()
|
||||
.dataMimeType(MimeTypeUtils.APPLICATION_JSON)
|
||||
.transport(this.transport);
|
||||
|
@ -132,7 +131,7 @@ public class DefaultRSocketRequesterBuilderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void mimeTypesCannotBeChangedAtRSocketConnectorLevel() {
|
||||
void mimeTypesCannotBeChangedAtRSocketConnectorLevel() {
|
||||
MimeType dataMimeType = MimeTypeUtils.APPLICATION_JSON;
|
||||
MimeType metaMimeType = MimeTypeUtils.parseMimeType(WellKnownMimeType.MESSAGE_RSOCKET_ROUTING.getString());
|
||||
|
||||
|
@ -154,7 +153,7 @@ public class DefaultRSocketRequesterBuilderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void setupRoute() {
|
||||
void setupRoute() {
|
||||
RSocketRequester requester = RSocketRequester.builder()
|
||||
.dataMimeType(MimeTypeUtils.TEXT_PLAIN)
|
||||
.metadataMimeType(MimeTypeUtils.TEXT_PLAIN)
|
||||
|
@ -169,7 +168,7 @@ public class DefaultRSocketRequesterBuilderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void setupWithAsyncValues() {
|
||||
void setupWithAsyncValues() {
|
||||
|
||||
Mono<String> asyncMeta1 = Mono.delay(Duration.ofMillis(1)).map(aLong -> "Async Metadata 1");
|
||||
Mono<String> asyncMeta2 = Mono.delay(Duration.ofMillis(1)).map(aLong -> "Async Metadata 2");
|
||||
|
@ -199,7 +198,7 @@ public class DefaultRSocketRequesterBuilderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void frameDecoderMatchesDataBufferFactory() throws Exception {
|
||||
void frameDecoderMatchesDataBufferFactory() throws Exception {
|
||||
testPayloadDecoder(new NettyDataBufferFactory(ByteBufAllocator.DEFAULT), PayloadDecoder.ZERO_COPY);
|
||||
testPayloadDecoder(DefaultDataBufferFactory.sharedInstance, PayloadDecoder.DEFAULT);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -51,7 +51,7 @@ import static org.springframework.util.MimeTypeUtils.TEXT_PLAIN;
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class DefaultRSocketRequesterTests {
|
||||
class DefaultRSocketRequesterTests {
|
||||
|
||||
private static final Duration MILLIS_10 = Duration.ofMillis(10);
|
||||
|
||||
|
@ -64,14 +64,14 @@ public class DefaultRSocketRequesterTests {
|
|||
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
void setUp() {
|
||||
this.rsocket = new TestRSocket();
|
||||
this.requester = RSocketRequester.wrap(this.rsocket, TEXT_PLAIN, TEXT_PLAIN, this.strategies);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void sendMono() {
|
||||
void sendMono() {
|
||||
|
||||
// data(Object)
|
||||
testSendMono(spec -> spec.data("bodyA"), "bodyA");
|
||||
|
@ -95,7 +95,7 @@ public class DefaultRSocketRequesterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendFlux() {
|
||||
void sendFlux() {
|
||||
String[] values = new String[] {"bodyA", "bodyB", "bodyC"};
|
||||
Flux<String> stringFlux = Flux.fromArray(values).delayElements(MILLIS_10);
|
||||
|
||||
|
@ -132,7 +132,7 @@ public class DefaultRSocketRequesterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendWithoutData() {
|
||||
void sendWithoutData() {
|
||||
this.requester.route("toA").send().block(Duration.ofSeconds(5));
|
||||
|
||||
assertThat(this.rsocket.getSavedMethodName()).isEqualTo("fireAndForget");
|
||||
|
@ -141,7 +141,7 @@ public class DefaultRSocketRequesterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSendWithAsyncMetadata() {
|
||||
void testSendWithAsyncMetadata() {
|
||||
|
||||
MimeType compositeMimeType =
|
||||
MimeTypeUtils.parseMimeType(WellKnownMimeType.MESSAGE_RSOCKET_COMPOSITE_METADATA.getString());
|
||||
|
@ -171,7 +171,7 @@ public class DefaultRSocketRequesterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void retrieveMono() {
|
||||
void retrieveMono() {
|
||||
String value = "bodyA";
|
||||
this.rsocket.setPayloadMonoToReturn(Mono.delay(MILLIS_10).thenReturn(toPayload(value)));
|
||||
Mono<String> response = this.requester.route("").data("").retrieveMono(String.class);
|
||||
|
@ -181,7 +181,7 @@ public class DefaultRSocketRequesterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void retrieveMonoVoid() {
|
||||
void retrieveMonoVoid() {
|
||||
AtomicBoolean consumed = new AtomicBoolean();
|
||||
Mono<Payload> mono = Mono.delay(MILLIS_10).thenReturn(toPayload("bodyA")).doOnSuccess(p -> consumed.set(true));
|
||||
this.rsocket.setPayloadMonoToReturn(mono);
|
||||
|
@ -192,7 +192,7 @@ public class DefaultRSocketRequesterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void retrieveMonoWithoutData() {
|
||||
void retrieveMonoWithoutData() {
|
||||
this.requester.route("toA").retrieveMono(String.class).block(Duration.ofSeconds(5));
|
||||
|
||||
assertThat(this.rsocket.getSavedMethodName()).isEqualTo("requestResponse");
|
||||
|
@ -201,7 +201,7 @@ public class DefaultRSocketRequesterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void retrieveFlux() {
|
||||
void retrieveFlux() {
|
||||
String[] values = new String[] {"bodyA", "bodyB", "bodyC"};
|
||||
this.rsocket.setPayloadFluxToReturn(Flux.fromArray(values).delayElements(MILLIS_10).map(this::toPayload));
|
||||
Flux<String> response = this.requester.route("").data("").retrieveFlux(String.class);
|
||||
|
@ -211,7 +211,7 @@ public class DefaultRSocketRequesterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void retrieveFluxVoid() {
|
||||
void retrieveFluxVoid() {
|
||||
AtomicBoolean consumed = new AtomicBoolean();
|
||||
Flux<Payload> flux = Flux.just("bodyA", "bodyB")
|
||||
.delayElements(MILLIS_10).map(this::toPayload).doOnComplete(() -> consumed.set(true));
|
||||
|
@ -223,7 +223,7 @@ public class DefaultRSocketRequesterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void retrieveFluxWithoutData() {
|
||||
void retrieveFluxWithoutData() {
|
||||
this.requester.route("toA").retrieveFlux(String.class).blockLast(Duration.ofSeconds(5));
|
||||
|
||||
assertThat(this.rsocket.getSavedMethodName()).isEqualTo("requestStream");
|
||||
|
@ -232,7 +232,7 @@ public class DefaultRSocketRequesterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fluxToMonoIsRejected() {
|
||||
void fluxToMonoIsRejected() {
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> this.requester.route("").data(Flux.just("a", "b")).retrieveMono(String.class))
|
||||
.withMessage("No RSocket interaction with Flux request and Mono response.");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -108,7 +108,6 @@ class DefaultRSocketStrategiesTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
void applyMetadataExtractors() {
|
||||
Consumer<MetadataExtractorRegistry> consumer = mock();
|
||||
RSocketStrategies.builder().metadataExtractorRegistry(consumer).build();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -106,7 +106,7 @@ public class LeakAwareNettyDataBufferFactory extends NettyDataBufferFactory {
|
|||
}
|
||||
|
||||
|
||||
private static record DataBufferLeakInfo(DataBuffer dataBuffer, AssertionError error) {
|
||||
private record DataBufferLeakInfo(DataBuffer dataBuffer, AssertionError error) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -47,7 +47,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
|||
*/
|
||||
class MetadataEncoderTests {
|
||||
|
||||
private static MimeType COMPOSITE_METADATA =
|
||||
private static final MimeType COMPOSITE_METADATA =
|
||||
MimeTypeUtils.parseMimeType(WellKnownMimeType.MESSAGE_RSOCKET_COMPOSITE_METADATA.getString());
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*/
|
||||
class PayloadUtilsTests {
|
||||
|
||||
private LeakAwareNettyDataBufferFactory nettyBufferFactory =
|
||||
private final LeakAwareNettyDataBufferFactory nettyBufferFactory =
|
||||
new LeakAwareNettyDataBufferFactory(PooledByteBufAllocator.DEFAULT);
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -157,7 +157,7 @@ class RSocketBufferLeakTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void echoChannel() {
|
||||
void echoChannel() {
|
||||
Flux<String> result = requester.route("echo-channel")
|
||||
.data(Flux.range(1, 10).map(i -> "Hello " + i), String.class)
|
||||
.retrieveFlux(String.class);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -58,7 +58,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
* @author Rossen Stoyanchev
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class RSocketClientToServerIntegrationTests {
|
||||
class RSocketClientToServerIntegrationTests {
|
||||
|
||||
private static final MimeType FOO_MIME_TYPE = MimeTypeUtils.parseMimeType("messaging/x.foo");
|
||||
|
||||
|
@ -103,7 +103,7 @@ public class RSocketClientToServerIntegrationTests {
|
|||
|
||||
|
||||
@Test
|
||||
public void fireAndForget() {
|
||||
void fireAndForget() {
|
||||
Flux.range(1, 3)
|
||||
.delayElements(Duration.ofMillis(10))
|
||||
.concatMap(i -> requester.route("receive").data("Hello " + i).send())
|
||||
|
@ -123,7 +123,7 @@ public class RSocketClientToServerIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void echo() {
|
||||
void echo() {
|
||||
Flux<String> result = Flux.range(1, 3).concatMap(i ->
|
||||
requester.route("echo").data("Hello " + i).retrieveMono(String.class));
|
||||
|
||||
|
@ -134,7 +134,7 @@ public class RSocketClientToServerIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void echoAsync() {
|
||||
void echoAsync() {
|
||||
Flux<String> result = Flux.range(1, 3).concatMap(i ->
|
||||
requester.route("echo-async").data("Hello " + i).retrieveMono(String.class));
|
||||
|
||||
|
@ -145,7 +145,7 @@ public class RSocketClientToServerIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void echoStream() {
|
||||
void echoStream() {
|
||||
Flux<String> result = requester.route("echo-stream").data("Hello").retrieveFlux(String.class);
|
||||
|
||||
StepVerifier.create(result)
|
||||
|
@ -155,7 +155,7 @@ public class RSocketClientToServerIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void echoChannel() {
|
||||
void echoChannel() {
|
||||
Flux<String> result = requester.route("echo-channel")
|
||||
.data(Flux.range(1, 10).map(i -> "Hello " + i), String.class)
|
||||
.retrieveFlux(String.class);
|
||||
|
@ -173,7 +173,7 @@ public class RSocketClientToServerIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void metadataPush() {
|
||||
void metadataPush() {
|
||||
Flux.just("bar", "baz")
|
||||
.delayElements(Duration.ofMillis(10))
|
||||
.concatMap(s -> requester.route("foo-updates").metadata(s, FOO_MIME_TYPE).sendMetadata())
|
||||
|
@ -192,19 +192,19 @@ public class RSocketClientToServerIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void voidReturnValue() {
|
||||
void voidReturnValue() {
|
||||
Mono<String> result = requester.route("void-return-value").data("Hello").retrieveMono(String.class);
|
||||
StepVerifier.create(result).expectComplete().verify(Duration.ofSeconds(5));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void voidReturnValueFromExceptionHandler() {
|
||||
void voidReturnValueFromExceptionHandler() {
|
||||
Mono<String> result = requester.route("void-return-value").data("bad").retrieveMono(String.class);
|
||||
StepVerifier.create(result).expectComplete().verify(Duration.ofSeconds(5));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleWithThrownException() {
|
||||
void handleWithThrownException() {
|
||||
Mono<String> result = requester.route("thrown-exception").data("a").retrieveMono(String.class);
|
||||
StepVerifier.create(result)
|
||||
.expectNext("Invalid input error handled")
|
||||
|
@ -213,7 +213,7 @@ public class RSocketClientToServerIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void handleWithErrorSignal() {
|
||||
void handleWithErrorSignal() {
|
||||
Mono<String> result = requester.route("error-signal").data("a").retrieveMono(String.class);
|
||||
StepVerifier.create(result)
|
||||
.expectNext("Invalid input error handled")
|
||||
|
@ -222,7 +222,7 @@ public class RSocketClientToServerIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void noMatchingRoute() {
|
||||
void noMatchingRoute() {
|
||||
Mono<String> result = requester.route("invalid").data("anything").retrieveMono(String.class);
|
||||
StepVerifier.create(result)
|
||||
.expectErrorMessage("No handler for destination 'invalid'")
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -121,7 +121,7 @@ class RSocketServerToClientIntegrationTests {
|
|||
|
||||
|
||||
@Controller
|
||||
@SuppressWarnings({"unused", "NullableProblems"})
|
||||
@SuppressWarnings("unused")
|
||||
static class ServerController {
|
||||
|
||||
// Must be initialized by @Test method...
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -33,14 +33,14 @@ import static org.springframework.messaging.rsocket.annotation.support.RSocketFr
|
|||
* Unit tests for {@link RSocketFrameTypeMessageCondition}.
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class RSocketFrameTypeMessageConditionTests {
|
||||
class RSocketFrameTypeMessageConditionTests {
|
||||
|
||||
private static final RSocketFrameTypeMessageCondition FNF_RR_CONDITION =
|
||||
new RSocketFrameTypeMessageCondition(FrameType.REQUEST_FNF, FrameType.REQUEST_RESPONSE);
|
||||
|
||||
|
||||
@Test
|
||||
public void getMatchingCondition() {
|
||||
void getMatchingCondition() {
|
||||
Message<?> message = message(FrameType.REQUEST_RESPONSE);
|
||||
RSocketFrameTypeMessageCondition actual = FNF_RR_CONDITION.getMatchingCondition(message);
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class RSocketFrameTypeMessageConditionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getMatchingConditionEmpty() {
|
||||
void getMatchingConditionEmpty() {
|
||||
Message<?> message = message(FrameType.REQUEST_RESPONSE);
|
||||
RSocketFrameTypeMessageCondition actual = EMPTY_CONDITION.getMatchingCondition(message);
|
||||
|
||||
|
@ -57,7 +57,7 @@ public class RSocketFrameTypeMessageConditionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void combine() {
|
||||
void combine() {
|
||||
|
||||
assertThat(EMPTY_CONDITION.combine(CONNECT_CONDITION).getFrameTypes())
|
||||
.containsExactly(FrameType.SETUP, FrameType.METADATA_PUSH);
|
||||
|
@ -67,7 +67,7 @@ public class RSocketFrameTypeMessageConditionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void compareTo() {
|
||||
void compareTo() {
|
||||
Message<byte[]> message = message(null);
|
||||
assertThat(condition(FrameType.SETUP).compareTo(condition(FrameType.SETUP), message)).isEqualTo(0);
|
||||
assertThat(condition(FrameType.SETUP).compareTo(condition(FrameType.METADATA_PUSH), message)).isEqualTo(0);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -56,10 +56,10 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
|||
* @author Rossen Stoyanchev
|
||||
* @since 5.2
|
||||
*/
|
||||
public class RSocketMessageHandlerTests {
|
||||
class RSocketMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void getRSocketStrategies() {
|
||||
void getRSocketStrategies() {
|
||||
RSocketMessageHandler handler = new RSocketMessageHandler();
|
||||
handler.setDecoders(Collections.singletonList(new ByteArrayDecoder()));
|
||||
handler.setEncoders(Collections.singletonList(new ByteArrayEncoder()));
|
||||
|
@ -77,7 +77,7 @@ public class RSocketMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void setRSocketStrategies() {
|
||||
void setRSocketStrategies() {
|
||||
RSocketStrategies strategies = RSocketStrategies.builder()
|
||||
.encoder(new ByteArrayEncoder())
|
||||
.decoder(new ByteArrayDecoder())
|
||||
|
@ -97,7 +97,7 @@ public class RSocketMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getRSocketStrategiesReflectsCurrentState() {
|
||||
void getRSocketStrategiesReflectsCurrentState() {
|
||||
|
||||
RSocketMessageHandler handler = new RSocketMessageHandler();
|
||||
|
||||
|
@ -132,7 +132,7 @@ public class RSocketMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void metadataExtractorWithExplicitlySetDecoders() {
|
||||
void metadataExtractorWithExplicitlySetDecoders() {
|
||||
DefaultMetadataExtractor extractor = new DefaultMetadataExtractor(StringDecoder.allMimeTypes());
|
||||
|
||||
RSocketMessageHandler handler = new RSocketMessageHandler();
|
||||
|
@ -145,7 +145,7 @@ public class RSocketMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void mappings() {
|
||||
void mappings() {
|
||||
testMapping(new SimpleController(), "path");
|
||||
testMapping(new TypeLevelMappingController(), "base.path");
|
||||
testMapping(new HandleAllController());
|
||||
|
@ -175,7 +175,7 @@ public class RSocketMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void rejectConnectMappingMethodsThatCanReply() {
|
||||
void rejectConnectMappingMethodsThatCanReply() {
|
||||
|
||||
RSocketMessageHandler handler = new RSocketMessageHandler();
|
||||
handler.setHandlers(Collections.singletonList(new InvalidConnectMappingController()));
|
||||
|
@ -196,7 +196,7 @@ public class RSocketMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void ignoreFireAndForgetToHandlerThatCanReply() {
|
||||
void ignoreFireAndForgetToHandlerThatCanReply() {
|
||||
|
||||
InteractionMismatchController controller = new InteractionMismatchController();
|
||||
|
||||
|
@ -217,7 +217,7 @@ public class RSocketMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void rejectRequestResponseToStreamingHandler() {
|
||||
void rejectRequestResponseToStreamingHandler() {
|
||||
|
||||
RSocketMessageHandler handler = new RSocketMessageHandler();
|
||||
handler.setHandlers(Collections.singletonList(new InteractionMismatchController()));
|
||||
|
@ -238,7 +238,7 @@ public class RSocketMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void handleNoMatch() {
|
||||
void handleNoMatch() {
|
||||
|
||||
testHandleNoMatch(FrameType.SETUP);
|
||||
testHandleNoMatch(FrameType.METADATA_PUSH);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
* Unit tests for {@link DestinationVariableArgumentResolver}.
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class DestinationVariableArgumentResolverTests extends RSocketServiceArgumentResolverTestSupport {
|
||||
class DestinationVariableArgumentResolverTests extends RSocketServiceArgumentResolverTestSupport {
|
||||
|
||||
@Override
|
||||
protected RSocketServiceArgumentResolver initResolver() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
* Unit tests for {@link MetadataArgumentResolver}.
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class MetadataArgumentResolverTests extends RSocketServiceArgumentResolverTestSupport {
|
||||
class MetadataArgumentResolverTests extends RSocketServiceArgumentResolverTestSupport {
|
||||
|
||||
@Override
|
||||
protected RSocketServiceArgumentResolver initResolver() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
|||
* Unit tests for {@link PayloadArgumentResolver}.
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class PayloadArgumentResolverTests extends RSocketServiceArgumentResolverTestSupport {
|
||||
class PayloadArgumentResolverTests extends RSocketServiceArgumentResolverTestSupport {
|
||||
|
||||
@Override
|
||||
protected RSocketServiceArgumentResolver initResolver() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
|||
* Unit tests for {@link RSocketRequestValues}.
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class RSocketRequestValuesTests {
|
||||
class RSocketRequestValuesTests {
|
||||
|
||||
@Test
|
||||
void route() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -39,7 +39,7 @@ import static org.springframework.util.MimeTypeUtils.TEXT_PLAIN;
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class RSocketServiceMethodTests {
|
||||
class RSocketServiceMethodTests {
|
||||
|
||||
private TestRSocket rsocket;
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class RSocketServiceMethodTests {
|
|||
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
void setUp() {
|
||||
this.rsocket = new TestRSocket();
|
||||
RSocketRequester requester = RSocketRequester.wrap(this.rsocket, TEXT_PLAIN, TEXT_PLAIN, RSocketStrategies.create());
|
||||
this.proxyFactory = RSocketServiceProxyFactory.builder(requester).build();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -42,25 +42,25 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
|||
* @author Rossen Stoyanchev
|
||||
* @since 4.1
|
||||
*/
|
||||
public class SimpAttributesContextHolderTests {
|
||||
class SimpAttributesContextHolderTests {
|
||||
|
||||
private SimpAttributes simpAttributes;
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
void setUp() {
|
||||
Map<String, Object> map = new ConcurrentHashMap<>();
|
||||
this.simpAttributes = new SimpAttributes("session1", map);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
void tearDown() {
|
||||
SimpAttributesContextHolder.resetAttributes();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void resetAttributes() {
|
||||
void resetAttributes() {
|
||||
SimpAttributesContextHolder.setAttributes(this.simpAttributes);
|
||||
assertThat(SimpAttributesContextHolder.getAttributes()).isSameAs(this.simpAttributes);
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class SimpAttributesContextHolderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getAttributes() {
|
||||
void getAttributes() {
|
||||
assertThat(SimpAttributesContextHolder.getAttributes()).isNull();
|
||||
|
||||
SimpAttributesContextHolder.setAttributes(this.simpAttributes);
|
||||
|
@ -77,7 +77,7 @@ public class SimpAttributesContextHolderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void setAttributes() {
|
||||
void setAttributes() {
|
||||
SimpAttributesContextHolder.setAttributes(this.simpAttributes);
|
||||
assertThat(SimpAttributesContextHolder.getAttributes()).isSameAs(this.simpAttributes);
|
||||
|
||||
|
@ -86,7 +86,7 @@ public class SimpAttributesContextHolderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void setAttributesFromMessage() {
|
||||
void setAttributesFromMessage() {
|
||||
|
||||
String sessionId = "session1";
|
||||
ConcurrentHashMap<String, Object> map = new ConcurrentHashMap<>();
|
||||
|
@ -107,14 +107,14 @@ public class SimpAttributesContextHolderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void setAttributesFromMessageWithMissingSessionId() {
|
||||
void setAttributesFromMessageWithMissingSessionId() {
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
SimpAttributesContextHolder.setAttributesFromMessage(new GenericMessage<Object>("")))
|
||||
.withMessageStartingWith("No session id in");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setAttributesFromMessageWithMissingSessionAttributes() {
|
||||
void setAttributesFromMessageWithMissingSessionAttributes() {
|
||||
SimpMessageHeaderAccessor headerAccessor = SimpMessageHeaderAccessor.create();
|
||||
headerAccessor.setSessionId("session1");
|
||||
Message<?> message = MessageBuilder.createMessage("", headerAccessor.getMessageHeaders());
|
||||
|
@ -124,13 +124,13 @@ public class SimpAttributesContextHolderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void currentAttributes() {
|
||||
void currentAttributes() {
|
||||
SimpAttributesContextHolder.setAttributes(this.simpAttributes);
|
||||
assertThat(SimpAttributesContextHolder.currentAttributes()).isSameAs(this.simpAttributes);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void currentAttributesNone() {
|
||||
void currentAttributesNone() {
|
||||
assertThatIllegalStateException().isThrownBy(SimpAttributesContextHolder::currentAttributes)
|
||||
.withMessageStartingWith("No thread-bound SimpAttributes found");
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -33,7 +33,7 @@ import static org.mockito.Mockito.verify;
|
|||
* @author Rossen Stoyanchev
|
||||
* @since 4.1
|
||||
*/
|
||||
public class SimpAttributesTests {
|
||||
class SimpAttributesTests {
|
||||
|
||||
private final Map<String, Object> map = new ConcurrentHashMap<>();
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class SimpAttributesTests {
|
|||
|
||||
|
||||
@Test
|
||||
public void getAttribute() {
|
||||
void getAttribute() {
|
||||
this.simpAttributes.setAttribute("name1", "value1");
|
||||
|
||||
assertThat(this.simpAttributes.getAttribute("name1")).isEqualTo("value1");
|
||||
|
@ -49,7 +49,7 @@ public class SimpAttributesTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getAttributeNames() {
|
||||
void getAttributeNames() {
|
||||
this.simpAttributes.setAttribute("name1", "value1");
|
||||
this.simpAttributes.setAttribute("name2", "value1");
|
||||
this.simpAttributes.setAttribute("name3", "value1");
|
||||
|
@ -59,7 +59,7 @@ public class SimpAttributesTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void registerDestructionCallback() {
|
||||
void registerDestructionCallback() {
|
||||
Runnable callback = mock();
|
||||
this.simpAttributes.registerDestructionCallback("name1", callback);
|
||||
|
||||
|
@ -68,7 +68,7 @@ public class SimpAttributesTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void registerDestructionCallbackAfterSessionCompleted() {
|
||||
void registerDestructionCallbackAfterSessionCompleted() {
|
||||
this.simpAttributes.sessionCompleted();
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> this.simpAttributes.registerDestructionCallback("name1", mock()))
|
||||
|
@ -76,7 +76,7 @@ public class SimpAttributesTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void removeDestructionCallback() {
|
||||
void removeDestructionCallback() {
|
||||
Runnable callback1 = mock();
|
||||
Runnable callback2 = mock();
|
||||
this.simpAttributes.registerDestructionCallback("name1", callback1);
|
||||
|
@ -86,12 +86,12 @@ public class SimpAttributesTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getSessionMutex() {
|
||||
void getSessionMutex() {
|
||||
assertThat(this.simpAttributes.getSessionMutex()).isSameAs(this.map);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSessionMutexExplicit() {
|
||||
void getSessionMutexExplicit() {
|
||||
Object mutex = new Object();
|
||||
this.simpAttributes.setAttribute(SimpAttributes.SESSION_MUTEX_NAME, mutex);
|
||||
|
||||
|
@ -99,7 +99,7 @@ public class SimpAttributesTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sessionCompleted() {
|
||||
void sessionCompleted() {
|
||||
Runnable callback1 = mock();
|
||||
Runnable callback2 = mock();
|
||||
this.simpAttributes.registerDestructionCallback("name1", callback1);
|
||||
|
@ -112,7 +112,7 @@ public class SimpAttributesTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sessionCompletedIsIdempotent() {
|
||||
void sessionCompletedIsIdempotent() {
|
||||
Runnable callback1 = mock();
|
||||
this.simpAttributes.registerDestructionCallback("name1", callback1);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -32,23 +32,23 @@ import static org.mockito.Mockito.mock;
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class SimpMessageHeaderAccessorTests {
|
||||
class SimpMessageHeaderAccessorTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void getShortLogMessage() {
|
||||
void getShortLogMessage() {
|
||||
assertThat(SimpMessageHeaderAccessor.create().getShortLogMessage("p"))
|
||||
.isEqualTo("MESSAGE session=null payload=p");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLogMessageWithValuesSet() {
|
||||
void getLogMessageWithValuesSet() {
|
||||
SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.create();
|
||||
accessor.setDestination("/destination");
|
||||
accessor.setSubscriptionId("subscription");
|
||||
accessor.setSessionId("session");
|
||||
accessor.setUser(new TestPrincipal("user"));
|
||||
accessor.setSessionAttributes(Collections.<String, Object>singletonMap("key", "value"));
|
||||
accessor.setSessionAttributes(Collections.singletonMap("key", "value"));
|
||||
|
||||
assertThat(accessor.getShortLogMessage("p"))
|
||||
.isEqualTo(("MESSAGE destination=/destination subscriptionId=subscription " +
|
||||
|
@ -56,13 +56,13 @@ public class SimpMessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getDetailedLogMessageWithValuesSet() {
|
||||
void getDetailedLogMessageWithValuesSet() {
|
||||
SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.create();
|
||||
accessor.setDestination("/destination");
|
||||
accessor.setSubscriptionId("subscription");
|
||||
accessor.setSessionId("session");
|
||||
accessor.setUser(new TestPrincipal("user"));
|
||||
accessor.setSessionAttributes(Collections.<String, Object>singletonMap("key", "value"));
|
||||
accessor.setSessionAttributes(Collections.singletonMap("key", "value"));
|
||||
accessor.setNativeHeader("nativeKey", "nativeValue");
|
||||
|
||||
assertThat(accessor.getDetailedLogMessage("p"))
|
||||
|
@ -72,7 +72,7 @@ public class SimpMessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void userChangeCallback() {
|
||||
void userChangeCallback() {
|
||||
UserCallback userCallback = new UserCallback();
|
||||
SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.create();
|
||||
accessor.setUserChangeCallback(userCallback);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -28,10 +28,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class SimpMessageTypeMessageConditionTests {
|
||||
class SimpMessageTypeMessageConditionTests {
|
||||
|
||||
@Test
|
||||
public void combine() {
|
||||
void combine() {
|
||||
SimpMessageType messageType = SimpMessageType.MESSAGE;
|
||||
SimpMessageType subscribeType = SimpMessageType.SUBSCRIBE;
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class SimpMessageTypeMessageConditionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getMatchingCondition() {
|
||||
void getMatchingCondition() {
|
||||
Message<?> message = message(SimpMessageType.MESSAGE);
|
||||
SimpMessageTypeMessageCondition condition = condition(SimpMessageType.MESSAGE);
|
||||
SimpMessageTypeMessageCondition actual = condition.getMatchingCondition(message);
|
||||
|
@ -56,7 +56,7 @@ public class SimpMessageTypeMessageConditionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getMatchingConditionNoMessageType() {
|
||||
void getMatchingConditionNoMessageType() {
|
||||
Message<?> message = message(null);
|
||||
SimpMessageTypeMessageCondition condition = condition(SimpMessageType.MESSAGE);
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class SimpMessageTypeMessageConditionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void compareTo() {
|
||||
void compareTo() {
|
||||
Message<byte[]> message = message(null);
|
||||
assertThat(condition(SimpMessageType.MESSAGE).compareTo(condition(SimpMessageType.MESSAGE), message)).isEqualTo(0);
|
||||
assertThat(condition(SimpMessageType.MESSAGE).compareTo(condition(SimpMessageType.SUBSCRIBE), message)).isEqualTo(0);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,7 +16,6 @@
|
|||
|
||||
package org.springframework.messaging.simp;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -43,7 +42,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class SimpMessagingTemplateTests {
|
||||
class SimpMessagingTemplateTests {
|
||||
|
||||
private SimpMessagingTemplate messagingTemplate;
|
||||
|
||||
|
@ -51,14 +50,14 @@ public class SimpMessagingTemplateTests {
|
|||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
void setup() {
|
||||
this.messageChannel = new StubMessageChannel();
|
||||
this.messagingTemplate = new SimpMessagingTemplate(this.messageChannel);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void convertAndSendToUser() {
|
||||
void convertAndSendToUser() {
|
||||
this.messagingTemplate.convertAndSendToUser("joe", "/queue/foo", "data");
|
||||
List<Message<byte[]>> messages = this.messageChannel.getMessages();
|
||||
|
||||
|
@ -74,7 +73,7 @@ public class SimpMessagingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void convertAndSendToUserWithEncoding() {
|
||||
void convertAndSendToUserWithEncoding() {
|
||||
this.messagingTemplate.convertAndSendToUser("https://joe.openid.example.org/", "/queue/foo", "data");
|
||||
List<Message<byte[]>> messages = this.messageChannel.getMessages();
|
||||
|
||||
|
@ -94,8 +93,8 @@ public class SimpMessagingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void convertAndSendWithCustomHeader() {
|
||||
Map<String, Object> headers = Collections.<String, Object>singletonMap("key", "value");
|
||||
void convertAndSendWithCustomHeader() {
|
||||
Map<String, Object> headers = Collections.singletonMap("key", "value");
|
||||
this.messagingTemplate.convertAndSend("/foo", "data", headers);
|
||||
|
||||
List<Message<byte[]>> messages = this.messageChannel.getMessages();
|
||||
|
@ -105,11 +104,11 @@ public class SimpMessagingTemplateTests {
|
|||
|
||||
assertThat(headerAccessor).isNotNull();
|
||||
assertThat(headerAccessor.toMap().get("key")).isNull();
|
||||
assertThat(headerAccessor.getNativeHeader("key")).isEqualTo(Arrays.asList("value"));
|
||||
assertThat(headerAccessor.getNativeHeader("key")).containsExactly("value");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertAndSendWithCustomHeaderNonNative() {
|
||||
void convertAndSendWithCustomHeaderNonNative() {
|
||||
Map<String, Object> headers = new HashMap<>();
|
||||
headers.put("key", "value");
|
||||
headers.put(NativeMessageHeaderAccessor.NATIVE_HEADERS, new LinkedMultiValueMap<String, String>());
|
||||
|
@ -128,7 +127,7 @@ public class SimpMessagingTemplateTests {
|
|||
// SPR-11868
|
||||
|
||||
@Test
|
||||
public void convertAndSendWithCustomDestinationPrefix() {
|
||||
void convertAndSendWithCustomDestinationPrefix() {
|
||||
this.messagingTemplate.setUserDestinationPrefix("/prefix");
|
||||
this.messagingTemplate.convertAndSendToUser("joe", "/queue/foo", "data");
|
||||
List<Message<byte[]>> messages = this.messageChannel.getMessages();
|
||||
|
@ -145,7 +144,7 @@ public class SimpMessagingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void convertAndSendWithMutableSimpMessageHeaders() {
|
||||
void convertAndSendWithMutableSimpMessageHeaders() {
|
||||
SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.create();
|
||||
accessor.setHeader("key", "value");
|
||||
accessor.setNativeHeader("fooNative", "barNative");
|
||||
|
@ -161,11 +160,11 @@ public class SimpMessagingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void processHeadersToSend() {
|
||||
void processHeadersToSend() {
|
||||
Map<String, Object> map = this.messagingTemplate.processHeadersToSend(null);
|
||||
|
||||
assertThat(map).isNotNull();
|
||||
assertThat(MessageHeaders.class.isAssignableFrom(map.getClass())).as("Actual: " + map.getClass().toString()).isTrue();
|
||||
assertThat(MessageHeaders.class.isAssignableFrom(map.getClass())).as("Actual: " + map.getClass()).isTrue();
|
||||
|
||||
SimpMessageHeaderAccessor headerAccessor =
|
||||
MessageHeaderAccessor.getAccessor((MessageHeaders) map, SimpMessageHeaderAccessor.class);
|
||||
|
@ -175,7 +174,7 @@ public class SimpMessagingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void doSendWithMutableHeaders() {
|
||||
void doSendWithMutableHeaders() {
|
||||
SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.create();
|
||||
accessor.setHeader("key", "value");
|
||||
accessor.setNativeHeader("fooNative", "barNative");
|
||||
|
@ -192,7 +191,7 @@ public class SimpMessagingTemplateTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void doSendWithStompHeaders() {
|
||||
void doSendWithStompHeaders() {
|
||||
StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.SUBSCRIBE);
|
||||
accessor.setDestination("/user/queue/foo");
|
||||
Message<?> message = MessageBuilder.createMessage(new byte[0], accessor.getMessageHeaders());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -36,7 +36,7 @@ import static org.mockito.Mockito.verify;
|
|||
* @author Rossen Stoyanchev
|
||||
* @since 4.1
|
||||
*/
|
||||
public class SimpSessionScopeTests {
|
||||
class SimpSessionScopeTests {
|
||||
|
||||
private SimpSessionScope scope = new SimpSessionScope();
|
||||
|
||||
|
@ -47,17 +47,17 @@ public class SimpSessionScopeTests {
|
|||
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
void setUp() {
|
||||
SimpAttributesContextHolder.setAttributes(this.simpAttributes);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
void tearDown() {
|
||||
SimpAttributesContextHolder.resetAttributes();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void get() {
|
||||
void get() {
|
||||
this.simpAttributes.setAttribute("name", "value");
|
||||
Object actual = this.scope.get("name", this.objectFactory);
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class SimpSessionScopeTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getWithObjectFactory() {
|
||||
void getWithObjectFactory() {
|
||||
given(this.objectFactory.getObject()).willReturn("value");
|
||||
Object actual = this.scope.get("name", this.objectFactory);
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class SimpSessionScopeTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void remove() {
|
||||
void remove() {
|
||||
this.simpAttributes.setAttribute("name", "value");
|
||||
|
||||
Object removed = this.scope.remove("name");
|
||||
|
@ -86,7 +86,7 @@ public class SimpSessionScopeTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void registerDestructionCallback() {
|
||||
void registerDestructionCallback() {
|
||||
Runnable runnable = mock();
|
||||
this.scope.registerDestructionCallback("name", runnable);
|
||||
|
||||
|
@ -95,7 +95,7 @@ public class SimpSessionScopeTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getSessionId() {
|
||||
void getSessionId() {
|
||||
assertThat(this.scope.getConversationId()).isEqualTo("session1");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
* @author Rossen Stoyanchev
|
||||
* @author Johnny Lim
|
||||
*/
|
||||
public class PrincipalMethodArgumentResolverTests {
|
||||
class PrincipalMethodArgumentResolverTests {
|
||||
|
||||
private final PrincipalMethodArgumentResolver resolver = new PrincipalMethodArgumentResolver();
|
||||
|
||||
|
@ -44,14 +44,14 @@ public class PrincipalMethodArgumentResolverTests {
|
|||
|
||||
|
||||
@Test
|
||||
public void supportsParameter() {
|
||||
void supportsParameter() {
|
||||
assertThat(this.resolver.supportsParameter(this.testMethod.arg(Principal.class))).isTrue();
|
||||
assertThat(this.resolver.supportsParameter(this.testMethod.arg(Optional.class, Principal.class))).isTrue();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void resolverArgument() {
|
||||
void resolverArgument() {
|
||||
Principal user = () -> "Joe";
|
||||
Message<String> message = new GenericMessage<>("Hello, world!",
|
||||
Collections.singletonMap(SimpMessageHeaderAccessor.USER_HEADER, user));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -122,7 +122,7 @@ public class SendToMethodReturnValueHandlerTests {
|
|||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
void setup() {
|
||||
SimpMessagingTemplate messagingTemplate = new SimpMessagingTemplate(this.messageChannel);
|
||||
messagingTemplate.setMessageConverter(new StringMessageConverter());
|
||||
this.handler = new SendToMethodReturnValueHandler(messagingTemplate, true);
|
||||
|
@ -134,7 +134,7 @@ public class SendToMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void supportsReturnType() throws Exception {
|
||||
void supportsReturnType() {
|
||||
assertThat(this.handler.supportsReturnType(this.sendToReturnType)).isTrue();
|
||||
assertThat(this.handler.supportsReturnType(this.sendToUserReturnType)).isTrue();
|
||||
assertThat(this.handler.supportsReturnType(this.noAnnotationsReturnType)).isFalse();
|
||||
|
@ -150,7 +150,7 @@ public class SendToMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendToNoAnnotations() throws Exception {
|
||||
void sendToNoAnnotations() throws Exception {
|
||||
given(this.messageChannel.send(any(Message.class))).willReturn(true);
|
||||
|
||||
String sessionId = "sess1";
|
||||
|
@ -162,7 +162,7 @@ public class SendToMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendTo() throws Exception {
|
||||
void sendTo() throws Exception {
|
||||
given(this.messageChannel.send(any(Message.class))).willReturn(true);
|
||||
|
||||
String sessionId = "sess1";
|
||||
|
@ -175,7 +175,7 @@ public class SendToMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendToDefaultDestination() throws Exception {
|
||||
void sendToDefaultDestination() throws Exception {
|
||||
given(this.messageChannel.send(any(Message.class))).willReturn(true);
|
||||
|
||||
String sessionId = "sess1";
|
||||
|
@ -187,7 +187,7 @@ public class SendToMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendToClassDefaultNoAnnotation() throws Exception {
|
||||
void sendToClassDefaultNoAnnotation() throws Exception {
|
||||
given(this.messageChannel.send(any(Message.class))).willReturn(true);
|
||||
|
||||
String sessionId = "sess1";
|
||||
|
@ -199,7 +199,7 @@ public class SendToMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendToClassDefaultEmptyAnnotation() throws Exception {
|
||||
void sendToClassDefaultEmptyAnnotation() throws Exception {
|
||||
given(this.messageChannel.send(any(Message.class))).willReturn(true);
|
||||
|
||||
String sessionId = "sess1";
|
||||
|
@ -211,7 +211,7 @@ public class SendToMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendToClassDefaultOverride() throws Exception {
|
||||
void sendToClassDefaultOverride() throws Exception {
|
||||
given(this.messageChannel.send(any(Message.class))).willReturn(true);
|
||||
|
||||
String sessionId = "sess1";
|
||||
|
@ -224,7 +224,7 @@ public class SendToMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendToUserClassDefaultNoAnnotation() throws Exception {
|
||||
void sendToUserClassDefaultNoAnnotation() throws Exception {
|
||||
given(this.messageChannel.send(any(Message.class))).willReturn(true);
|
||||
|
||||
String sessionId = "sess1";
|
||||
|
@ -236,7 +236,7 @@ public class SendToMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendToUserClassDefaultEmptyAnnotation() throws Exception {
|
||||
void sendToUserClassDefaultEmptyAnnotation() throws Exception {
|
||||
given(this.messageChannel.send(any(Message.class))).willReturn(true);
|
||||
|
||||
String sessionId = "sess1";
|
||||
|
@ -248,7 +248,7 @@ public class SendToMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendToUserClassDefaultOverride() throws Exception {
|
||||
void sendToUserClassDefaultOverride() throws Exception {
|
||||
given(this.messageChannel.send(any(Message.class))).willReturn(true);
|
||||
|
||||
String sessionId = "sess1";
|
||||
|
@ -306,7 +306,7 @@ public class SendToMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendToDefaultDestinationWhenUsingDotPathSeparator() throws Exception {
|
||||
void sendToDefaultDestinationWhenUsingDotPathSeparator() throws Exception {
|
||||
given(this.messageChannel.send(any(Message.class))).willReturn(true);
|
||||
|
||||
Message<?> inputMessage = createMessage("sess1", "sub1", "/app/", "dest.foo.bar", null);
|
||||
|
@ -319,7 +319,7 @@ public class SendToMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testHeadersToSend() throws Exception {
|
||||
void testHeadersToSend() throws Exception {
|
||||
Message<?> message = createMessage("sess1", "sub1", "/app", "/dest", null);
|
||||
|
||||
SimpMessageSendingOperations messagingTemplate = mock();
|
||||
|
@ -341,7 +341,7 @@ public class SendToMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendToUser() throws Exception {
|
||||
void sendToUser() throws Exception {
|
||||
given(this.messageChannel.send(any(Message.class))).willReturn(true);
|
||||
|
||||
String sessionId = "sess1";
|
||||
|
@ -363,7 +363,7 @@ public class SendToMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendToAndSendToUser() throws Exception {
|
||||
void sendToAndSendToUser() throws Exception {
|
||||
given(this.messageChannel.send(any(Message.class))).willReturn(true);
|
||||
|
||||
String sessionId = "sess1";
|
||||
|
@ -417,7 +417,7 @@ public class SendToMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendToUserSingleSession() throws Exception {
|
||||
void sendToUserSingleSession() throws Exception {
|
||||
given(this.messageChannel.send(any(Message.class))).willReturn(true);
|
||||
|
||||
String sessionId = "sess1";
|
||||
|
@ -443,7 +443,7 @@ public class SendToMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendToUserWithUserNameProvider() throws Exception {
|
||||
void sendToUserWithUserNameProvider() throws Exception {
|
||||
given(this.messageChannel.send(any(Message.class))).willReturn(true);
|
||||
|
||||
String sessionId = "sess1";
|
||||
|
@ -461,7 +461,7 @@ public class SendToMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendToUserDefaultDestination() throws Exception {
|
||||
void sendToUserDefaultDestination() throws Exception {
|
||||
given(this.messageChannel.send(any(Message.class))).willReturn(true);
|
||||
|
||||
String sessionId = "sess1";
|
||||
|
@ -478,7 +478,7 @@ public class SendToMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendToUserDefaultDestinationWhenUsingDotPathSeparator() throws Exception {
|
||||
void sendToUserDefaultDestinationWhenUsingDotPathSeparator() throws Exception {
|
||||
given(this.messageChannel.send(any(Message.class))).willReturn(true);
|
||||
|
||||
TestUser user = new TestUser();
|
||||
|
@ -492,7 +492,7 @@ public class SendToMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendToUserDefaultDestinationSingleSession() throws Exception {
|
||||
void sendToUserDefaultDestinationSingleSession() throws Exception {
|
||||
given(this.messageChannel.send(any(Message.class))).willReturn(true);
|
||||
|
||||
String sessionId = "sess1";
|
||||
|
@ -511,7 +511,7 @@ public class SendToMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendToUserSessionWithoutUserName() throws Exception {
|
||||
void sendToUserSessionWithoutUserName() throws Exception {
|
||||
given(this.messageChannel.send(any(Message.class))).willReturn(true);
|
||||
|
||||
String sessionId = "sess1";
|
||||
|
@ -530,7 +530,7 @@ public class SendToMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void jsonView() throws Exception {
|
||||
void jsonView() throws Exception {
|
||||
given(this.messageChannel.send(any(Message.class))).willReturn(true);
|
||||
|
||||
String sessionId = "sess1";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -99,7 +99,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
|||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
void setup() {
|
||||
SimpMessagingTemplate brokerTemplate = new SimpMessagingTemplate(this.channel);
|
||||
brokerTemplate.setMessageConverter(this.converter);
|
||||
|
||||
|
@ -124,7 +124,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void optionalHeaderArgumentResolutionWhenPresent() {
|
||||
void optionalHeaderArgumentResolutionWhenPresent() {
|
||||
Map<String, Object> headers = Collections.singletonMap("foo", "bar");
|
||||
Message<?> message = createMessage("/pre/optionalHeaders", headers);
|
||||
this.messageHandler.registerHandler(this.testController);
|
||||
|
@ -136,7 +136,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void optionalHeaderArgumentResolutionWhenNotPresent() {
|
||||
void optionalHeaderArgumentResolutionWhenNotPresent() {
|
||||
Message<?> message = createMessage("/pre/optionalHeaders");
|
||||
this.messageHandler.registerHandler(this.testController);
|
||||
this.messageHandler.handleMessage(message);
|
||||
|
@ -147,7 +147,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void messageMappingDestinationVariableResolution() {
|
||||
void messageMappingDestinationVariableResolution() {
|
||||
Message<?> message = createMessage("/pre/message/bar/value");
|
||||
this.messageHandler.registerHandler(this.testController);
|
||||
this.messageHandler.handleMessage(message);
|
||||
|
@ -158,7 +158,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void subscribeEventDestinationVariableResolution() {
|
||||
void subscribeEventDestinationVariableResolution() {
|
||||
Message<?> message = createMessage(SimpMessageType.SUBSCRIBE, "/pre/sub/bar/value", null);
|
||||
this.messageHandler.registerHandler(this.testController);
|
||||
this.messageHandler.handleMessage(message);
|
||||
|
@ -169,7 +169,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void simpleBinding() {
|
||||
void simpleBinding() {
|
||||
Message<?> message = createMessage("/pre/binding/id/12");
|
||||
this.messageHandler.registerHandler(this.testController);
|
||||
this.messageHandler.handleMessage(message);
|
||||
|
@ -180,7 +180,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void validationError() {
|
||||
void validationError() {
|
||||
Message<?> message = createMessage("/pre/validation/payload");
|
||||
this.messageHandler.registerHandler(this.testController);
|
||||
this.messageHandler.handleMessage(message);
|
||||
|
@ -189,7 +189,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void exceptionWithHandlerMethodArg() {
|
||||
void exceptionWithHandlerMethodArg() {
|
||||
Message<?> message = createMessage("/pre/illegalState");
|
||||
this.messageHandler.registerHandler(this.testController);
|
||||
this.messageHandler.handleMessage(message);
|
||||
|
@ -201,7 +201,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void exceptionAsCause() {
|
||||
void exceptionAsCause() {
|
||||
Message<?> message = createMessage("/pre/illegalStateCause");
|
||||
this.messageHandler.registerHandler(this.testController);
|
||||
this.messageHandler.handleMessage(message);
|
||||
|
@ -213,7 +213,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void errorAsMessageHandlingException() {
|
||||
void errorAsMessageHandlingException() {
|
||||
Message<?> message = createMessage("/pre/error");
|
||||
this.messageHandler.registerHandler(this.testController);
|
||||
this.messageHandler.handleMessage(message);
|
||||
|
@ -225,7 +225,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void simpScope() {
|
||||
void simpScope() {
|
||||
Map<String, Object> sessionAttributes = new ConcurrentHashMap<>();
|
||||
sessionAttributes.put("name", "value");
|
||||
|
||||
|
@ -241,7 +241,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void interfaceBasedController() {
|
||||
void interfaceBasedController() {
|
||||
InterfaceBasedController controller = new InterfaceBasedController();
|
||||
|
||||
Message<?> message = createMessage("/pre/binding/id/12");
|
||||
|
@ -254,7 +254,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void dotPathSeparator() {
|
||||
void dotPathSeparator() {
|
||||
DotPathSeparatorController controller = new DotPathSeparatorController();
|
||||
|
||||
this.messageHandler.setPathMatcher(new AntPathMatcher("."));
|
||||
|
@ -294,7 +294,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void listenableFutureFailure() {
|
||||
void listenableFutureFailure() {
|
||||
ListenableFutureController controller = new ListenableFutureController();
|
||||
this.messageHandler.registerHandler(controller);
|
||||
this.messageHandler.setDestinationPrefixes(Arrays.asList("/app1", "/app2/"));
|
||||
|
@ -327,7 +327,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void completableFutureFailure() {
|
||||
void completableFutureFailure() {
|
||||
CompletableFutureController controller = new CompletableFutureController();
|
||||
this.messageHandler.registerHandler(controller);
|
||||
this.messageHandler.setDestinationPrefixes(Arrays.asList("/app1", "/app2/"));
|
||||
|
@ -360,7 +360,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void monoFailure() {
|
||||
void monoFailure() {
|
||||
ReactiveController controller = new ReactiveController();
|
||||
this.messageHandler.registerHandler(controller);
|
||||
this.messageHandler.setDestinationPrefixes(Arrays.asList("/app1", "/app2/"));
|
||||
|
@ -373,7 +373,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fluxNotHandled() {
|
||||
void fluxNotHandled() {
|
||||
ReactiveController controller = new ReactiveController();
|
||||
this.messageHandler.registerHandler(controller);
|
||||
this.messageHandler.setDestinationPrefixes(Arrays.asList("/app1", "/app2/"));
|
||||
|
@ -388,7 +388,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void placeholder() {
|
||||
void placeholder() {
|
||||
Message<?> message = createMessage("/pre/myValue");
|
||||
this.messageHandler.setEmbeddedValueResolver(value -> ("/${myProperty}".equals(value) ? "/myValue" : value));
|
||||
this.messageHandler.registerHandler(this.testController);
|
||||
|
@ -453,7 +453,7 @@ public class SimpAnnotationMethodMessageHandlerTests {
|
|||
public void optionalHeaders(@Header(name="foo", required=false) String foo1, @Header("foo") Optional<String> foo2) {
|
||||
this.method = "optionalHeaders";
|
||||
this.arguments.put("foo1", foo1);
|
||||
this.arguments.put("foo2", (foo2.isPresent() ? foo2.get() : null));
|
||||
this.arguments.put("foo2", (foo2.orElse(null)));
|
||||
}
|
||||
|
||||
@MessageMapping("/message/{foo}/{name}")
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -86,7 +86,7 @@ public class SubscriptionMethodReturnValueHandlerTests {
|
|||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() throws Exception {
|
||||
void setup() throws Exception {
|
||||
SimpMessagingTemplate messagingTemplate = new SimpMessagingTemplate(this.messageChannel);
|
||||
messagingTemplate.setMessageConverter(new StringMessageConverter());
|
||||
this.handler = new SubscriptionMethodReturnValueHandler(messagingTemplate);
|
||||
|
@ -110,14 +110,14 @@ public class SubscriptionMethodReturnValueHandlerTests {
|
|||
|
||||
|
||||
@Test
|
||||
public void supportsReturnType() throws Exception {
|
||||
void supportsReturnType() {
|
||||
assertThat(this.handler.supportsReturnType(this.subscribeEventReturnType)).isTrue();
|
||||
assertThat(this.handler.supportsReturnType(this.subscribeEventSendToReturnType)).isFalse();
|
||||
assertThat(this.handler.supportsReturnType(this.messageMappingReturnType)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMessageSentToChannel() throws Exception {
|
||||
void testMessageSentToChannel() throws Exception {
|
||||
given(this.messageChannel.send(any(Message.class))).willReturn(true);
|
||||
|
||||
String sessionId = "sess1";
|
||||
|
@ -169,7 +169,7 @@ public class SubscriptionMethodReturnValueHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testJsonView() throws Exception {
|
||||
void testJsonView() throws Exception {
|
||||
given(this.messageChannel.send(any(Message.class))).willReturn(true);
|
||||
|
||||
String sessionId = "sess1";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -39,20 +39,20 @@ import static org.mockito.Mockito.mock;
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class BrokerMessageHandlerTests {
|
||||
class BrokerMessageHandlerTests {
|
||||
|
||||
private final TestBrokerMessageHandler handler = new TestBrokerMessageHandler();
|
||||
|
||||
|
||||
@Test
|
||||
public void startShouldUpdateIsRunning() {
|
||||
void startShouldUpdateIsRunning() {
|
||||
assertThat(this.handler.isRunning()).isFalse();
|
||||
this.handler.start();
|
||||
assertThat(this.handler.isRunning()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stopShouldUpdateIsRunning() {
|
||||
void stopShouldUpdateIsRunning() {
|
||||
this.handler.start();
|
||||
assertThat(this.handler.isRunning()).isTrue();
|
||||
|
||||
|
@ -61,20 +61,20 @@ public class BrokerMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void startAndStopShouldNotPublishBrokerAvailabilityEvents() {
|
||||
void startAndStopShouldNotPublishBrokerAvailabilityEvents() {
|
||||
this.handler.start();
|
||||
this.handler.stop();
|
||||
assertThat(this.handler.availabilityEvents).isEqualTo(Collections.emptyList());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleMessageWhenBrokerNotRunning() {
|
||||
void handleMessageWhenBrokerNotRunning() {
|
||||
this.handler.handleMessage(new GenericMessage<Object>("payload"));
|
||||
assertThat(this.handler.messages).isEqualTo(Collections.emptyList());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void publishBrokerAvailableEvent() {
|
||||
void publishBrokerAvailableEvent() {
|
||||
assertThat(this.handler.isBrokerAvailable()).isFalse();
|
||||
assertThat(this.handler.availabilityEvents).isEqualTo(Collections.emptyList());
|
||||
|
||||
|
@ -85,7 +85,7 @@ public class BrokerMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void publishBrokerAvailableEventWhenAlreadyAvailable() {
|
||||
void publishBrokerAvailableEventWhenAlreadyAvailable() {
|
||||
this.handler.publishBrokerAvailableEvent();
|
||||
this.handler.publishBrokerAvailableEvent();
|
||||
|
||||
|
@ -93,7 +93,7 @@ public class BrokerMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void publishBrokerUnavailableEvent() {
|
||||
void publishBrokerUnavailableEvent() {
|
||||
this.handler.publishBrokerAvailableEvent();
|
||||
assertThat(this.handler.isBrokerAvailable()).isTrue();
|
||||
|
||||
|
@ -104,7 +104,7 @@ public class BrokerMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void publishBrokerUnavailableEventWhenAlreadyUnavailable() {
|
||||
void publishBrokerUnavailableEventWhenAlreadyUnavailable() {
|
||||
this.handler.publishBrokerAvailableEvent();
|
||||
this.handler.publishBrokerUnavailableEvent();
|
||||
this.handler.publishBrokerUnavailableEvent();
|
||||
|
@ -113,7 +113,7 @@ public class BrokerMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void checkDestination() {
|
||||
void checkDestination() {
|
||||
TestBrokerMessageHandler theHandler = new TestBrokerMessageHandler("/topic");
|
||||
theHandler.start();
|
||||
|
||||
|
@ -136,7 +136,7 @@ public class BrokerMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void checkDestinationWithoutConfiguredPrefixes() {
|
||||
void checkDestinationWithoutConfiguredPrefixes() {
|
||||
this.handler.setUserDestinationPredicate(destination -> destination.startsWith("/user/"));
|
||||
this.handler.start();
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -420,7 +420,7 @@ class DefaultSubscriptionRegistryTests {
|
|||
}
|
||||
|
||||
@Test // SPR-12665
|
||||
void findSubscriptionsReturnsMapSafeToIterate() throws Exception {
|
||||
void findSubscriptionsReturnsMapSafeToIterate() {
|
||||
this.registry.registerSubscription(subscribeMessage("sess1", "1", "/foo"));
|
||||
this.registry.registerSubscription(subscribeMessage("sess2", "1", "/foo"));
|
||||
|
||||
|
@ -437,7 +437,7 @@ class DefaultSubscriptionRegistryTests {
|
|||
}
|
||||
|
||||
@Test // SPR-13185
|
||||
void findSubscriptionsReturnsMapSafeToIterateIncludingValues() throws Exception {
|
||||
void findSubscriptionsReturnsMapSafeToIterateIncludingValues() {
|
||||
this.registry.registerSubscription(subscribeMessage("sess1", "1", "/foo"));
|
||||
this.registry.registerSubscription(subscribeMessage("sess1", "2", "/foo"));
|
||||
|
||||
|
@ -454,7 +454,7 @@ class DefaultSubscriptionRegistryTests {
|
|||
}
|
||||
|
||||
@Test // SPR-13555
|
||||
void cacheLimitExceeded() throws Exception {
|
||||
void cacheLimitExceeded() {
|
||||
this.registry.setCacheLimit(1);
|
||||
this.registry.registerSubscription(subscribeMessage("sess1", "1", "/foo"));
|
||||
this.registry.registerSubscription(subscribeMessage("sess1", "2", "/bar"));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
* @author Rossen Stoyanchev
|
||||
* @see org.springframework.web.socket.messaging.OrderedMessageSendingIntegrationTests
|
||||
*/
|
||||
public class OrderedMessageChannelDecoratorTests {
|
||||
class OrderedMessageChannelDecoratorTests {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(OrderedMessageChannelDecoratorTests.class);
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class OrderedMessageChannelDecoratorTests {
|
|||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
void setup() {
|
||||
this.executor = new ThreadPoolTaskExecutor();
|
||||
this.executor.setCorePoolSize(Runtime.getRuntime().availableProcessors() * 2);
|
||||
this.executor.setAllowCoreThreadTimeOut(true);
|
||||
|
@ -60,13 +60,13 @@ public class OrderedMessageChannelDecoratorTests {
|
|||
}
|
||||
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
void tearDown() {
|
||||
this.executor.shutdown();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test() throws InterruptedException {
|
||||
void test() throws InterruptedException {
|
||||
|
||||
int start = 1;
|
||||
int end = 1000;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -82,14 +82,14 @@ public class SimpleBrokerMessageHandlerTests {
|
|||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
void setup() {
|
||||
this.messageHandler = new SimpleBrokerMessageHandler(
|
||||
this.clientInChannel, this.clientOutChannel, this.brokerChannel, Collections.emptyList());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void subscribePublish() {
|
||||
void subscribePublish() {
|
||||
startSession("sess1");
|
||||
startSession("sess2");
|
||||
|
||||
|
@ -114,7 +114,7 @@ public class SimpleBrokerMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void subscribeDisconnectPublish() {
|
||||
void subscribeDisconnectPublish() {
|
||||
String sess1 = "sess1";
|
||||
String sess2 = "sess2";
|
||||
|
||||
|
@ -152,7 +152,7 @@ public class SimpleBrokerMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void connect() {
|
||||
void connect() {
|
||||
String id = "sess1";
|
||||
|
||||
Message<String> connectMessage = startSession(id);
|
||||
|
@ -166,7 +166,7 @@ public class SimpleBrokerMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void heartbeatValueWithAndWithoutTaskScheduler() {
|
||||
void heartbeatValueWithAndWithoutTaskScheduler() {
|
||||
assertThat(this.messageHandler.getHeartbeatValue()).isNull();
|
||||
this.messageHandler.setTaskScheduler(this.taskScheduler);
|
||||
|
||||
|
@ -175,7 +175,7 @@ public class SimpleBrokerMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void startWithHeartbeatValueWithoutTaskScheduler() {
|
||||
void startWithHeartbeatValueWithoutTaskScheduler() {
|
||||
this.messageHandler.setHeartbeatValue(new long[] {10000, 10000});
|
||||
assertThatIllegalArgumentException().isThrownBy(
|
||||
this.messageHandler::start);
|
||||
|
@ -201,7 +201,7 @@ public class SimpleBrokerMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void startWithOneZeroHeartbeatValue() {
|
||||
void startWithOneZeroHeartbeatValue() {
|
||||
this.messageHandler.setTaskScheduler(this.taskScheduler);
|
||||
this.messageHandler.setHeartbeatValue(new long[] {0, 10000});
|
||||
this.messageHandler.start();
|
||||
|
@ -210,7 +210,7 @@ public class SimpleBrokerMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void readInactivity() throws Exception {
|
||||
void readInactivity() throws Exception {
|
||||
this.messageHandler.setHeartbeatValue(new long[] {0, 1});
|
||||
this.messageHandler.setTaskScheduler(this.taskScheduler);
|
||||
this.messageHandler.start();
|
||||
|
@ -241,7 +241,7 @@ public class SimpleBrokerMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void writeInactivity() throws Exception {
|
||||
void writeInactivity() throws Exception {
|
||||
this.messageHandler.setHeartbeatValue(new long[] {1, 0});
|
||||
this.messageHandler.setTaskScheduler(this.taskScheduler);
|
||||
this.messageHandler.start();
|
||||
|
@ -272,7 +272,7 @@ public class SimpleBrokerMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void readWriteIntervalCalculation() throws Exception {
|
||||
void readWriteIntervalCalculation() throws Exception {
|
||||
this.messageHandler.setHeartbeatValue(new long[] {1, 1});
|
||||
this.messageHandler.setTaskScheduler(this.taskScheduler);
|
||||
this.messageHandler.start();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -92,10 +92,10 @@ import static org.mockito.Mockito.mock;
|
|||
* @author Brian Clozel
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class MessageBrokerConfigurationTests {
|
||||
class MessageBrokerConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void clientInboundChannel() {
|
||||
void clientInboundChannel() {
|
||||
ApplicationContext context = loadConfig(SimpleBrokerConfig.class);
|
||||
|
||||
TestChannel channel = context.getBean("clientInboundChannel", TestChannel.class);
|
||||
|
@ -108,7 +108,7 @@ public class MessageBrokerConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void clientInboundChannelWithBrokerRelay() {
|
||||
void clientInboundChannelWithBrokerRelay() {
|
||||
ApplicationContext context = loadConfig(BrokerRelayConfig.class);
|
||||
|
||||
TestChannel channel = context.getBean("clientInboundChannel", TestChannel.class);
|
||||
|
@ -121,7 +121,7 @@ public class MessageBrokerConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void clientInboundChannelCustomized() {
|
||||
void clientInboundChannelCustomized() {
|
||||
ApplicationContext context = loadConfig(CustomConfig.class);
|
||||
|
||||
AbstractSubscribableChannel channel = context.getBean(
|
||||
|
@ -136,7 +136,7 @@ public class MessageBrokerConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void clientOutboundChannelUsedByAnnotatedMethod() {
|
||||
void clientOutboundChannelUsedByAnnotatedMethod() {
|
||||
ApplicationContext context = loadConfig(SimpleBrokerConfig.class);
|
||||
|
||||
TestChannel channel = context.getBean("clientOutboundChannel", TestChannel.class);
|
||||
|
@ -161,7 +161,7 @@ public class MessageBrokerConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void clientOutboundChannelUsedBySimpleBroker() {
|
||||
void clientOutboundChannelUsedBySimpleBroker() {
|
||||
ApplicationContext context = loadConfig(SimpleBrokerConfig.class);
|
||||
|
||||
TestChannel outboundChannel = context.getBean("clientOutboundChannel", TestChannel.class);
|
||||
|
@ -194,7 +194,7 @@ public class MessageBrokerConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void clientOutboundChannelCustomized() {
|
||||
void clientOutboundChannelCustomized() {
|
||||
ApplicationContext context = loadConfig(CustomConfig.class);
|
||||
|
||||
AbstractSubscribableChannel channel = context.getBean(
|
||||
|
@ -215,7 +215,7 @@ public class MessageBrokerConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void brokerChannel() {
|
||||
void brokerChannel() {
|
||||
ApplicationContext context = loadConfig(SimpleBrokerConfig.class);
|
||||
|
||||
TestChannel channel = context.getBean("brokerChannel", TestChannel.class);
|
||||
|
@ -229,7 +229,7 @@ public class MessageBrokerConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void brokerChannelWithBrokerRelay() {
|
||||
void brokerChannelWithBrokerRelay() {
|
||||
ApplicationContext context = loadConfig(BrokerRelayConfig.class);
|
||||
|
||||
TestChannel channel = context.getBean("brokerChannel", TestChannel.class);
|
||||
|
@ -241,7 +241,7 @@ public class MessageBrokerConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void brokerChannelUsedByAnnotatedMethod() {
|
||||
void brokerChannelUsedByAnnotatedMethod() {
|
||||
ApplicationContext context = loadConfig(SimpleBrokerConfig.class);
|
||||
|
||||
TestChannel channel = context.getBean("brokerChannel", TestChannel.class);
|
||||
|
@ -265,7 +265,7 @@ public class MessageBrokerConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void brokerChannelCustomized() {
|
||||
void brokerChannelCustomized() {
|
||||
ApplicationContext context = loadConfig(CustomConfig.class);
|
||||
|
||||
AbstractSubscribableChannel channel = context.getBean(
|
||||
|
@ -282,7 +282,7 @@ public class MessageBrokerConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void configureMessageConvertersDefault() {
|
||||
void configureMessageConvertersDefault() {
|
||||
AbstractMessageBrokerConfiguration config = new BaseTestMessageBrokerConfig();
|
||||
CompositeMessageConverter compositeConverter = config.brokerMessageConverter();
|
||||
|
||||
|
@ -298,7 +298,7 @@ public class MessageBrokerConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void threadPoolSizeDefault() {
|
||||
void threadPoolSizeDefault() {
|
||||
ApplicationContext context = loadConfig(DefaultConfig.class);
|
||||
|
||||
String name = "clientInboundChannelExecutor";
|
||||
|
@ -317,7 +317,7 @@ public class MessageBrokerConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void configureMessageConvertersCustom() {
|
||||
void configureMessageConvertersCustom() {
|
||||
final MessageConverter testConverter = mock();
|
||||
AbstractMessageBrokerConfiguration config = new BaseTestMessageBrokerConfig() {
|
||||
@Override
|
||||
|
@ -334,7 +334,7 @@ public class MessageBrokerConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void configureMessageConvertersCustomAndDefault() {
|
||||
void configureMessageConvertersCustomAndDefault() {
|
||||
final MessageConverter testConverter = mock();
|
||||
|
||||
AbstractMessageBrokerConfiguration config = new BaseTestMessageBrokerConfig() {
|
||||
|
@ -356,7 +356,7 @@ public class MessageBrokerConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void customArgumentAndReturnValueTypes() {
|
||||
void customArgumentAndReturnValueTypes() {
|
||||
ApplicationContext context = loadConfig(CustomConfig.class);
|
||||
|
||||
SimpAnnotationMethodMessageHandler handler =
|
||||
|
@ -372,7 +372,7 @@ public class MessageBrokerConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void simpValidatorDefault() {
|
||||
void simpValidatorDefault() {
|
||||
AbstractMessageBrokerConfiguration config = new BaseTestMessageBrokerConfig() {};
|
||||
config.setApplicationContext(new StaticApplicationContext());
|
||||
|
||||
|
@ -381,7 +381,7 @@ public class MessageBrokerConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void simpValidatorCustom() {
|
||||
void simpValidatorCustom() {
|
||||
final Validator validator = mock();
|
||||
AbstractMessageBrokerConfiguration config = new BaseTestMessageBrokerConfig() {
|
||||
@Override
|
||||
|
@ -394,7 +394,7 @@ public class MessageBrokerConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void simpValidatorMvc() {
|
||||
void simpValidatorMvc() {
|
||||
StaticApplicationContext appCxt = new StaticApplicationContext();
|
||||
appCxt.registerSingleton("mvcValidator", TestValidator.class);
|
||||
AbstractMessageBrokerConfiguration config = new BaseTestMessageBrokerConfig() {};
|
||||
|
@ -405,7 +405,7 @@ public class MessageBrokerConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void simpValidatorInjected() {
|
||||
void simpValidatorInjected() {
|
||||
ApplicationContext context = loadConfig(SimpleBrokerConfig.class);
|
||||
|
||||
SimpAnnotationMethodMessageHandler messageHandler =
|
||||
|
@ -415,7 +415,7 @@ public class MessageBrokerConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void customPathMatcher() {
|
||||
void customPathMatcher() {
|
||||
ApplicationContext context = loadConfig(CustomConfig.class);
|
||||
|
||||
SimpleBrokerMessageHandler broker = context.getBean(SimpleBrokerMessageHandler.class);
|
||||
|
@ -433,7 +433,7 @@ public class MessageBrokerConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void customCacheLimit() {
|
||||
void customCacheLimit() {
|
||||
ApplicationContext context = loadConfig(CustomConfig.class);
|
||||
|
||||
SimpleBrokerMessageHandler broker = context.getBean(SimpleBrokerMessageHandler.class);
|
||||
|
@ -442,7 +442,7 @@ public class MessageBrokerConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void customUserRegistryOrder() {
|
||||
void customUserRegistryOrder() {
|
||||
ApplicationContext context = loadConfig(CustomConfig.class);
|
||||
|
||||
SimpUserRegistry registry = context.getBean(SimpUserRegistry.class);
|
||||
|
@ -451,7 +451,7 @@ public class MessageBrokerConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void userBroadcasts() {
|
||||
void userBroadcasts() {
|
||||
ApplicationContext context = loadConfig(BrokerRelayConfig.class);
|
||||
|
||||
SimpUserRegistry userRegistry = context.getBean(SimpUserRegistry.class);
|
||||
|
@ -471,7 +471,7 @@ public class MessageBrokerConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void userBroadcastsDisabledWithSimpleBroker() {
|
||||
void userBroadcastsDisabledWithSimpleBroker() {
|
||||
ApplicationContext context = loadConfig(SimpleBrokerConfig.class);
|
||||
|
||||
SimpUserRegistry registry = context.getBean(SimpUserRegistry.class);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -32,10 +32,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class StompBrokerRelayRegistrationTests {
|
||||
class StompBrokerRelayRegistrationTests {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
void test() {
|
||||
|
||||
SubscribableChannel inChannel = new StubMessageChannel();
|
||||
MessageChannel outChannel = new StubMessageChannel();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -77,7 +77,7 @@ public abstract class AbstractStompBrokerRelayIntegrationTests {
|
|||
|
||||
|
||||
@BeforeEach
|
||||
public void setup(TestInfo testInfo) throws Exception {
|
||||
void setup(TestInfo testInfo) throws Exception {
|
||||
logger.debug("Setting up before '" + testInfo.getTestMethod().get().getName() + "'");
|
||||
|
||||
this.responseChannel = new ExecutorSubscribableChannel();
|
||||
|
@ -130,7 +130,7 @@ public abstract class AbstractStompBrokerRelayIntegrationTests {
|
|||
protected abstract TcpOperations<byte[]> initTcpClient(int port);
|
||||
|
||||
@AfterEach
|
||||
public void stop() throws Exception {
|
||||
void stop() throws Exception {
|
||||
try {
|
||||
logger.debug("STOMP broker relay stats: " + this.relay.getStatsInfo());
|
||||
this.relay.stop();
|
||||
|
@ -155,7 +155,7 @@ public abstract class AbstractStompBrokerRelayIntegrationTests {
|
|||
|
||||
|
||||
@Test
|
||||
public void publishSubscribe() throws Exception {
|
||||
void publishSubscribe() throws Exception {
|
||||
logger.debug("Starting test publishSubscribe()");
|
||||
|
||||
String sess1 = "sess1";
|
||||
|
@ -179,7 +179,7 @@ public abstract class AbstractStompBrokerRelayIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void messageDeliveryExceptionIfSystemSessionForwardFails() throws Exception {
|
||||
void messageDeliveryExceptionIfSystemSessionForwardFails() throws Exception {
|
||||
logger.debug("Starting test messageDeliveryExceptionIfSystemSessionForwardFails()");
|
||||
|
||||
stopActiveMqBrokerAndAwait();
|
||||
|
@ -191,7 +191,7 @@ public abstract class AbstractStompBrokerRelayIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void brokerBecomingUnavailableTriggersErrorFrame() throws Exception {
|
||||
void brokerBecomingUnavailableTriggersErrorFrame() throws Exception {
|
||||
logger.debug("Starting test brokerBecomingUnavailableTriggersErrorFrame()");
|
||||
|
||||
String sess1 = "sess1";
|
||||
|
@ -206,7 +206,7 @@ public abstract class AbstractStompBrokerRelayIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void brokerAvailabilityEventWhenStopped() throws Exception {
|
||||
void brokerAvailabilityEventWhenStopped() throws Exception {
|
||||
logger.debug("Starting test brokerAvailabilityEventWhenStopped()");
|
||||
|
||||
stopActiveMqBrokerAndAwait();
|
||||
|
@ -214,7 +214,7 @@ public abstract class AbstractStompBrokerRelayIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void relayReconnectsIfBrokerComesBackUp() throws Exception {
|
||||
void relayReconnectsIfBrokerComesBackUp() throws Exception {
|
||||
logger.debug("Starting test relayReconnectsIfBrokerComesBackUp()");
|
||||
|
||||
String sess1 = "sess1";
|
||||
|
@ -240,7 +240,7 @@ public abstract class AbstractStompBrokerRelayIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void disconnectWithReceipt() throws Exception {
|
||||
void disconnectWithReceipt() throws Exception {
|
||||
logger.debug("Starting test disconnectWithReceipt()");
|
||||
|
||||
MessageExchange connect = MessageExchangeBuilder.connect("sess1").build();
|
||||
|
@ -443,7 +443,7 @@ public abstract class AbstractStompBrokerRelayIntegrationTests {
|
|||
}
|
||||
|
||||
public MessageExchange build() {
|
||||
return new MessageExchange(this.message, this.expected.toArray(new MessageMatcher[this.expected.size()]));
|
||||
return new MessageExchange(this.message, this.expected.toArray(new MessageMatcher[0]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -34,13 +34,13 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
|||
* @author Rossen Stoyanchev
|
||||
* @since 4.0.3
|
||||
*/
|
||||
public class BufferingStompDecoderTests {
|
||||
class BufferingStompDecoderTests {
|
||||
|
||||
private final StompDecoder STOMP_DECODER = new StompDecoder();
|
||||
private static final StompDecoder STOMP_DECODER = new StompDecoder();
|
||||
|
||||
|
||||
@Test
|
||||
public void basic() throws InterruptedException {
|
||||
void basic() {
|
||||
BufferingStompDecoder stompDecoder = new BufferingStompDecoder(STOMP_DECODER, 128);
|
||||
String chunk = "SEND\na:alpha\n\nMessage body\0";
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class BufferingStompDecoderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void oneMessageInTwoChunks() throws InterruptedException {
|
||||
void oneMessageInTwoChunks() {
|
||||
BufferingStompDecoder stompDecoder = new BufferingStompDecoder(STOMP_DECODER, 128);
|
||||
String chunk1 = "SEND\na:alpha\n\nMessage";
|
||||
String chunk2 = " body\0";
|
||||
|
@ -70,7 +70,7 @@ public class BufferingStompDecoderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void twoMessagesInOneChunk() throws InterruptedException {
|
||||
void twoMessagesInOneChunk() {
|
||||
BufferingStompDecoder stompDecoder = new BufferingStompDecoder(STOMP_DECODER, 128);
|
||||
String chunk = """
|
||||
SEND
|
||||
|
@ -91,7 +91,7 @@ public class BufferingStompDecoderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void oneFullAndOneSplitMessageContentLength() throws InterruptedException {
|
||||
void oneFullAndOneSplitMessageContentLength() {
|
||||
BufferingStompDecoder stompDecoder = new BufferingStompDecoder(STOMP_DECODER, 128);
|
||||
int contentLength = "Payload2a-Payload2b".getBytes().length;
|
||||
String chunk1 = "SEND\na:alpha\n\nPayload1\0SEND\ncontent-length:" + contentLength + "\n";
|
||||
|
@ -120,7 +120,7 @@ public class BufferingStompDecoderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void oneFullAndOneSplitMessageNoContentLength() throws InterruptedException {
|
||||
void oneFullAndOneSplitMessageNoContentLength() {
|
||||
BufferingStompDecoder stompDecoder = new BufferingStompDecoder(STOMP_DECODER, 128);
|
||||
String chunk1 = "SEND\na:alpha\n\nPayload1\0SEND\na:alpha\n";
|
||||
List<Message<byte[]>> messages = stompDecoder.decode(toByteBuffer(chunk1));
|
||||
|
@ -148,7 +148,7 @@ public class BufferingStompDecoderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void oneFullAndOneSplitWithContentLengthExceedingBufferSize() throws InterruptedException {
|
||||
void oneFullAndOneSplitWithContentLengthExceedingBufferSize() {
|
||||
BufferingStompDecoder stompDecoder = new BufferingStompDecoder(STOMP_DECODER, 128);
|
||||
String chunk1 = "SEND\na:alpha\n\nPayload1\0SEND\ncontent-length:129\n";
|
||||
List<Message<byte[]>> messages = stompDecoder.decode(toByteBuffer(chunk1));
|
||||
|
@ -165,7 +165,7 @@ public class BufferingStompDecoderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void bufferSizeLimit() {
|
||||
void bufferSizeLimit() {
|
||||
BufferingStompDecoder stompDecoder = new BufferingStompDecoder(STOMP_DECODER, 10);
|
||||
String payload = "SEND\na:alpha\n\nMessage body";
|
||||
assertThatExceptionOfType(StompConversionException.class).isThrownBy(() ->
|
||||
|
@ -173,7 +173,7 @@ public class BufferingStompDecoderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void incompleteCommand() {
|
||||
void incompleteCommand() {
|
||||
BufferingStompDecoder stompDecoder = new BufferingStompDecoder(STOMP_DECODER, 128);
|
||||
String chunk = "MESSAG";
|
||||
|
||||
|
@ -184,7 +184,7 @@ public class BufferingStompDecoderTests {
|
|||
// SPR-13416
|
||||
|
||||
@Test
|
||||
public void incompleteHeaderWithPartialEscapeSequence() throws Exception {
|
||||
void incompleteHeaderWithPartialEscapeSequence() {
|
||||
BufferingStompDecoder stompDecoder = new BufferingStompDecoder(STOMP_DECODER, 128);
|
||||
String chunk = "SEND\na:long\\";
|
||||
|
||||
|
@ -193,7 +193,7 @@ public class BufferingStompDecoderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void invalidEscapeSequence() {
|
||||
void invalidEscapeSequence() {
|
||||
BufferingStompDecoder stompDecoder = new BufferingStompDecoder(STOMP_DECODER, 128);
|
||||
String payload = "SEND\na:alpha\\x\\n\nMessage body\0";
|
||||
assertThatExceptionOfType(StompConversionException.class).isThrownBy(() ->
|
||||
|
@ -201,7 +201,7 @@ public class BufferingStompDecoderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void invalidEscapeSequenceWithSingleSlashAtEndOfHeaderValue() {
|
||||
void invalidEscapeSequenceWithSingleSlashAtEndOfHeaderValue() {
|
||||
BufferingStompDecoder stompDecoder = new BufferingStompDecoder(STOMP_DECODER, 128);
|
||||
String payload = "SEND\na:alpha\\\n\nMessage body\0";
|
||||
assertThatExceptionOfType(StompConversionException.class).isThrownBy(() ->
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -83,7 +83,7 @@ public class DefaultStompSessionTests {
|
|||
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
void setUp() {
|
||||
this.connectHeaders = new StompHeaders();
|
||||
this.session = new DefaultStompSession(this.sessionHandler, this.connectHeaders);
|
||||
this.session.setMessageConverter(
|
||||
|
@ -97,7 +97,7 @@ public class DefaultStompSessionTests {
|
|||
|
||||
|
||||
@Test
|
||||
public void afterConnected() {
|
||||
void afterConnected() {
|
||||
assertThat(this.session.isConnected()).isFalse();
|
||||
this.connectHeaders.setHost("my-host");
|
||||
this.connectHeaders.setHeartbeat(new long[] {11, 12});
|
||||
|
@ -127,7 +127,7 @@ public class DefaultStompSessionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void afterConnectFailure() {
|
||||
void afterConnectFailure() {
|
||||
IllegalStateException exception = new IllegalStateException("simulated exception");
|
||||
this.session.afterConnectFailure(exception);
|
||||
verify(this.sessionHandler).handleTransportError(this.session, exception);
|
||||
|
@ -135,7 +135,7 @@ public class DefaultStompSessionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void handleConnectedFrame() {
|
||||
void handleConnectedFrame() {
|
||||
this.session.afterConnected(this.connection);
|
||||
assertThat(this.session.isConnected()).isTrue();
|
||||
|
||||
|
@ -153,7 +153,7 @@ public class DefaultStompSessionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void heartbeatValues() {
|
||||
void heartbeatValues() {
|
||||
this.session.afterConnected(this.connection);
|
||||
assertThat(this.session.isConnected()).isTrue();
|
||||
|
||||
|
@ -175,7 +175,7 @@ public class DefaultStompSessionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void heartbeatNotSupportedByServer() {
|
||||
void heartbeatNotSupportedByServer() {
|
||||
this.session.afterConnected(this.connection);
|
||||
verify(this.connection).sendAsync(any());
|
||||
|
||||
|
@ -191,7 +191,7 @@ public class DefaultStompSessionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void heartbeatTasks() {
|
||||
void heartbeatTasks() {
|
||||
this.session.afterConnected(this.connection);
|
||||
verify(this.connection).sendAsync(any());
|
||||
|
||||
|
@ -226,7 +226,7 @@ public class DefaultStompSessionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void handleErrorFrame() {
|
||||
void handleErrorFrame() {
|
||||
StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.ERROR);
|
||||
accessor.setContentType(new MimeType("text", "plain", StandardCharsets.UTF_8));
|
||||
accessor.addNativeHeader("foo", "bar");
|
||||
|
@ -245,7 +245,7 @@ public class DefaultStompSessionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void handleErrorFrameWithEmptyPayload() {
|
||||
void handleErrorFrameWithEmptyPayload() {
|
||||
StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.ERROR);
|
||||
accessor.addNativeHeader("foo", "bar");
|
||||
accessor.setLeaveMutable(true);
|
||||
|
@ -257,7 +257,7 @@ public class DefaultStompSessionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void handleErrorFrameWithConversionException() {
|
||||
void handleErrorFrameWithConversionException() {
|
||||
StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.ERROR);
|
||||
accessor.setContentType(MimeTypeUtils.APPLICATION_JSON);
|
||||
accessor.addNativeHeader("foo", "bar");
|
||||
|
@ -276,7 +276,7 @@ public class DefaultStompSessionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void handleMessageFrame() {
|
||||
void handleMessageFrame() {
|
||||
this.session.afterConnected(this.connection);
|
||||
|
||||
StompFrameHandler frameHandler = mock();
|
||||
|
@ -303,7 +303,7 @@ public class DefaultStompSessionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void handleMessageFrameWithConversionException() {
|
||||
void handleMessageFrameWithConversionException() {
|
||||
this.session.afterConnected(this.connection);
|
||||
assertThat(this.session.isConnected()).isTrue();
|
||||
|
||||
|
@ -333,7 +333,7 @@ public class DefaultStompSessionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void handleFailure() {
|
||||
void handleFailure() {
|
||||
IllegalStateException exception = new IllegalStateException("simulated exception");
|
||||
this.session.handleFailure(exception);
|
||||
|
||||
|
@ -342,7 +342,7 @@ public class DefaultStompSessionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void afterConnectionClosed() {
|
||||
void afterConnectionClosed() {
|
||||
this.session.afterConnectionClosed();
|
||||
|
||||
verify(this.sessionHandler).handleTransportError(same(this.session), any(ConnectionLostException.class));
|
||||
|
@ -350,7 +350,7 @@ public class DefaultStompSessionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void send() {
|
||||
void send() {
|
||||
this.session.afterConnected(this.connection);
|
||||
assertThat(this.session.isConnected()).isTrue();
|
||||
|
||||
|
@ -373,7 +373,7 @@ public class DefaultStompSessionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendWithReceipt() {
|
||||
void sendWithReceipt() {
|
||||
this.session.afterConnected(this.connection);
|
||||
assertThat(this.session.isConnected()).isTrue();
|
||||
|
||||
|
@ -416,7 +416,7 @@ public class DefaultStompSessionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendWithConversionException() {
|
||||
void sendWithConversionException() {
|
||||
this.session.afterConnected(this.connection);
|
||||
assertThat(this.session.isConnected()).isTrue();
|
||||
|
||||
|
@ -430,7 +430,7 @@ public class DefaultStompSessionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendWithExecutionException() {
|
||||
void sendWithExecutionException() {
|
||||
this.session.afterConnected(this.connection);
|
||||
assertThat(this.session.isConnected()).isTrue();
|
||||
|
||||
|
@ -444,7 +444,7 @@ public class DefaultStompSessionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void subscribe() {
|
||||
void subscribe() {
|
||||
this.session.afterConnected(this.connection);
|
||||
assertThat(this.session.isConnected()).isTrue();
|
||||
|
||||
|
@ -463,7 +463,7 @@ public class DefaultStompSessionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void subscribeWithHeaders() {
|
||||
void subscribeWithHeaders() {
|
||||
this.session.afterConnected(this.connection);
|
||||
assertThat(this.session.isConnected()).isTrue();
|
||||
|
||||
|
@ -489,7 +489,7 @@ public class DefaultStompSessionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void unsubscribe() {
|
||||
void unsubscribe() {
|
||||
this.session.afterConnected(this.connection);
|
||||
assertThat(this.session.isConnected()).isTrue();
|
||||
|
||||
|
@ -536,7 +536,7 @@ public class DefaultStompSessionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void ack() {
|
||||
void ack() {
|
||||
this.session.afterConnected(this.connection);
|
||||
assertThat(this.session.isConnected()).isTrue();
|
||||
|
||||
|
@ -553,7 +553,7 @@ public class DefaultStompSessionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void nack() {
|
||||
void nack() {
|
||||
this.session.afterConnected(this.connection);
|
||||
assertThat(this.session.isConnected()).isTrue();
|
||||
|
||||
|
@ -570,7 +570,7 @@ public class DefaultStompSessionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void receiptReceived() {
|
||||
void receiptReceived() {
|
||||
this.session.afterConnected(this.connection);
|
||||
this.session.setTaskScheduler(mock());
|
||||
|
||||
|
@ -597,12 +597,11 @@ public class DefaultStompSessionTests {
|
|||
assertThat(received.get()).isNotNull();
|
||||
assertThat(received.get()).isTrue();
|
||||
assertThat(receivedHeaders.get()).isNotNull();
|
||||
assertThat(receivedHeaders.get().get("foo")).hasSize(1);
|
||||
assertThat(receivedHeaders.get().get("foo")).element(0).isEqualTo("bar");
|
||||
assertThat(receivedHeaders.get().get("foo")).containsExactly("bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void receiptReceivedBeforeTaskAdded() {
|
||||
void receiptReceivedBeforeTaskAdded() {
|
||||
this.session.afterConnected(this.connection);
|
||||
this.session.setTaskScheduler(mock());
|
||||
|
||||
|
@ -628,8 +627,7 @@ public class DefaultStompSessionTests {
|
|||
assertThat(received.get()).isNotNull();
|
||||
assertThat(received.get()).isTrue();
|
||||
assertThat(receivedHeaders.get()).isNotNull();
|
||||
assertThat(receivedHeaders.get().get("foo")).hasSize(1);
|
||||
assertThat(receivedHeaders.get().get("foo")).element(0).isEqualTo("bar");
|
||||
assertThat(receivedHeaders.get().get("foo")).containsExactly("bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -665,7 +663,7 @@ public class DefaultStompSessionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void disconnect() {
|
||||
void disconnect() {
|
||||
this.session.afterConnected(this.connection);
|
||||
assertThat(this.session.isConnected()).isTrue();
|
||||
|
||||
|
@ -675,7 +673,7 @@ public class DefaultStompSessionTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void disconnectWithHeaders() {
|
||||
void disconnectWithHeaders() {
|
||||
this.session.afterConnected(this.connection);
|
||||
assertThat(this.session.isConnected()).isTrue();
|
||||
|
||||
|
@ -688,8 +686,7 @@ public class DefaultStompSessionTests {
|
|||
StompHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class);
|
||||
headers = StompHeaders.readOnlyStompHeaders(accessor.getNativeHeaders());
|
||||
assertThat(headers).as(headers.toString()).hasSize(1);
|
||||
assertThat(headers.get("foo")).hasSize(1);
|
||||
assertThat(headers.get("foo")).element(0).isEqualTo("bar");
|
||||
assertThat(headers.get("foo")).containsExactly("bar");
|
||||
|
||||
assertThat(this.session.isConnected()).isFalse();
|
||||
verifyNoMoreInteractions(this.sessionHandler);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,7 +25,7 @@ import org.springframework.messaging.tcp.reactor.ReactorNettyTcpClient;
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class ReactorNettyStompBrokerRelayIntegrationTests extends AbstractStompBrokerRelayIntegrationTests {
|
||||
class ReactorNettyStompBrokerRelayIntegrationTests extends AbstractStompBrokerRelayIntegrationTests {
|
||||
|
||||
@Override
|
||||
protected TcpOperations<byte[]> initTcpClient(int port) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -49,7 +49,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
* @author Rossen Stoyanchev
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
public class ReactorNettyTcpStompClientTests {
|
||||
class ReactorNettyTcpStompClientTests {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(ReactorNettyTcpStompClientTests.class);
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class ReactorNettyTcpStompClientTests {
|
|||
|
||||
|
||||
@BeforeEach
|
||||
public void setup(TestInfo testInfo) throws Exception {
|
||||
void setup(TestInfo testInfo) throws Exception {
|
||||
logger.debug("Setting up before '" + testInfo.getTestMethod().get().getName() + "'");
|
||||
|
||||
TransportConnector stompConnector = createStompConnector();
|
||||
|
@ -97,7 +97,7 @@ public class ReactorNettyTcpStompClientTests {
|
|||
}
|
||||
|
||||
@AfterEach
|
||||
public void shutdown() throws Exception {
|
||||
void shutdown() throws Exception {
|
||||
try {
|
||||
this.client.shutdown();
|
||||
this.client2.shutdown();
|
||||
|
@ -116,12 +116,12 @@ public class ReactorNettyTcpStompClientTests {
|
|||
|
||||
|
||||
@Test
|
||||
public void publishSubscribeOnReactorNetty() throws Exception {
|
||||
void publishSubscribeOnReactorNetty() throws Exception {
|
||||
testPublishSubscribe(this.client);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void publishSubscribeOnReactorNetty2() throws Exception {
|
||||
void publishSubscribeOnReactorNetty2() throws Exception {
|
||||
testPublishSubscribe(this.client2);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -26,13 +26,13 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class StompClientSupportTests {
|
||||
class StompClientSupportTests {
|
||||
|
||||
private final StompClientSupport stompClient = new StompClientSupport() {};
|
||||
|
||||
|
||||
@Test
|
||||
public void defaultHeartbeatValidation() throws Exception {
|
||||
void defaultHeartbeatValidation() {
|
||||
trySetDefaultHeartbeat(new long[] {-1, 0});
|
||||
trySetDefaultHeartbeat(new long[] {0, -1});
|
||||
}
|
||||
|
@ -43,12 +43,12 @@ public class StompClientSupportTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void defaultHeartbeatValue() throws Exception {
|
||||
void defaultHeartbeatValue() {
|
||||
assertThat(this.stompClient.getDefaultHeartbeat()).isEqualTo(new long[] {10000, 10000});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isDefaultHeartbeatEnabled() throws Exception {
|
||||
void isDefaultHeartbeatEnabled() {
|
||||
assertThat(this.stompClient.getDefaultHeartbeat()).isEqualTo(new long[] {10000, 10000});
|
||||
assertThat(this.stompClient.isDefaultHeartbeatEnabled()).isTrue();
|
||||
|
||||
|
@ -57,7 +57,7 @@ public class StompClientSupportTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void processConnectHeadersDefault() throws Exception {
|
||||
void processConnectHeadersDefault() {
|
||||
StompHeaders connectHeaders = this.stompClient.processConnectHeaders(null);
|
||||
|
||||
assertThat(connectHeaders).isNotNull();
|
||||
|
@ -65,7 +65,7 @@ public class StompClientSupportTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void processConnectHeadersWithExplicitHeartbeat() throws Exception {
|
||||
void processConnectHeadersWithExplicitHeartbeat() {
|
||||
|
||||
StompHeaders connectHeaders = new StompHeaders();
|
||||
connectHeaders.setHeartbeat(new long[] {15000, 15000});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
/**
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class StompCommandTests {
|
||||
class StompCommandTests {
|
||||
|
||||
private static final Collection<StompCommand> destinationRequired =
|
||||
Arrays.asList(StompCommand.SEND, StompCommand.SUBSCRIBE, StompCommand.MESSAGE);
|
||||
|
@ -59,7 +59,7 @@ public class StompCommandTests {
|
|||
|
||||
|
||||
@Test
|
||||
public void getMessageType() throws Exception {
|
||||
void getMessageType() {
|
||||
for (StompCommand stompCommand : StompCommand.values()) {
|
||||
SimpMessageType simp = messageTypes.get(stompCommand);
|
||||
if (simp == null) {
|
||||
|
@ -70,28 +70,28 @@ public class StompCommandTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void requiresDestination() throws Exception {
|
||||
void requiresDestination() {
|
||||
for (StompCommand stompCommand : StompCommand.values()) {
|
||||
assertThat(stompCommand.requiresDestination()).isEqualTo(destinationRequired.contains(stompCommand));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void requiresSubscriptionId() throws Exception {
|
||||
void requiresSubscriptionId() {
|
||||
for (StompCommand stompCommand : StompCommand.values()) {
|
||||
assertThat(stompCommand.requiresSubscriptionId()).isEqualTo(subscriptionIdRequired.contains(stompCommand));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void requiresContentLength() throws Exception {
|
||||
void requiresContentLength() {
|
||||
for (StompCommand stompCommand : StompCommand.values()) {
|
||||
assertThat(stompCommand.requiresContentLength()).isEqualTo(contentLengthRequired.contains(stompCommand));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isBodyAllowed() throws Exception {
|
||||
void isBodyAllowed() {
|
||||
for (StompCommand stompCommand : StompCommand.values()) {
|
||||
assertThat(stompCommand.isBodyAllowed()).isEqualTo(bodyAllowed.contains(stompCommand));
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -34,13 +34,13 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
|||
* @author Andy Wilkinson
|
||||
* @author Stephane Maldini
|
||||
*/
|
||||
public class StompDecoderTests {
|
||||
class StompDecoderTests {
|
||||
|
||||
private final StompDecoder decoder = new StompDecoder();
|
||||
|
||||
|
||||
@Test
|
||||
public void decodeFrameWithCrLfEols() {
|
||||
void decodeFrameWithCrLfEols() {
|
||||
Message<byte[]> frame = decode("DISCONNECT\r\n\r\n\0");
|
||||
StompHeaderAccessor headers = StompHeaderAccessor.wrap(frame);
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class StompDecoderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void decodeFrameWithNoHeadersAndNoBody() {
|
||||
void decodeFrameWithNoHeadersAndNoBody() {
|
||||
Message<byte[]> frame = decode("DISCONNECT\n\n\0");
|
||||
StompHeaderAccessor headers = StompHeaderAccessor.wrap(frame);
|
||||
|
||||
|
@ -60,7 +60,7 @@ public class StompDecoderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void decodeFrameWithNoBody() {
|
||||
void decodeFrameWithNoBody() {
|
||||
String accept = "accept-version:1.1\n";
|
||||
String host = "host:github.org\n";
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class StompDecoderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void decodeFrame() {
|
||||
void decodeFrame() {
|
||||
Message<byte[]> frame = decode("SEND\ndestination:test\n\nThe body of the message\0");
|
||||
StompHeaderAccessor headers = StompHeaderAccessor.wrap(frame);
|
||||
|
||||
|
@ -91,7 +91,7 @@ public class StompDecoderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void decodeFrameWithContentLength() {
|
||||
void decodeFrameWithContentLength() {
|
||||
Message<byte[]> message = decode("SEND\ncontent-length:23\n\nThe body of the message\0");
|
||||
StompHeaderAccessor headers = StompHeaderAccessor.wrap(message);
|
||||
|
||||
|
@ -107,7 +107,7 @@ public class StompDecoderTests {
|
|||
// SPR-11528
|
||||
|
||||
@Test
|
||||
public void decodeFrameWithInvalidContentLength() {
|
||||
void decodeFrameWithInvalidContentLength() {
|
||||
Message<byte[]> message = decode("SEND\ncontent-length:-1\n\nThe body of the message\0");
|
||||
StompHeaderAccessor headers = StompHeaderAccessor.wrap(message);
|
||||
|
||||
|
@ -121,7 +121,7 @@ public class StompDecoderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void decodeFrameWithContentLengthZero() {
|
||||
void decodeFrameWithContentLengthZero() {
|
||||
Message<byte[]> frame = decode("SEND\ncontent-length:0\n\n\0");
|
||||
StompHeaderAccessor headers = StompHeaderAccessor.wrap(frame);
|
||||
|
||||
|
@ -135,7 +135,7 @@ public class StompDecoderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void decodeFrameWithNullOctectsInTheBody() {
|
||||
void decodeFrameWithNullOctectsInTheBody() {
|
||||
Message<byte[]> frame = decode("SEND\ncontent-length:23\n\nThe b\0dy \0f the message\0");
|
||||
StompHeaderAccessor headers = StompHeaderAccessor.wrap(frame);
|
||||
|
||||
|
@ -149,7 +149,7 @@ public class StompDecoderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void decodeFrameWithEscapedHeaders() {
|
||||
void decodeFrameWithEscapedHeaders() {
|
||||
Message<byte[]> frame = decode("DISCONNECT\na\\c\\r\\n\\\\b:alpha\\cbravo\\r\\n\\\\\n\n\0");
|
||||
StompHeaderAccessor headers = StompHeaderAccessor.wrap(frame);
|
||||
|
||||
|
@ -177,7 +177,7 @@ public class StompDecoderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void decodeFrameBodyNotAllowed() {
|
||||
void decodeFrameBodyNotAllowed() {
|
||||
assertThatExceptionOfType(StompConversionException.class).isThrownBy(() ->
|
||||
decode("CONNECT\naccept-version:1.2\n\nThe body of the message\0"));
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ public class StompDecoderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void decodeMultipleFramesFromSameBuffer() {
|
||||
void decodeMultipleFramesFromSameBuffer() {
|
||||
String frame1 = "SEND\ndestination:test\n\nThe body of the message\0";
|
||||
String frame2 = "DISCONNECT\n\n\0";
|
||||
ByteBuffer buffer = ByteBuffer.wrap((frame1 + frame2).getBytes());
|
||||
|
@ -224,48 +224,48 @@ public class StompDecoderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void decodeFrameWithIncompleteCommand() {
|
||||
void decodeFrameWithIncompleteCommand() {
|
||||
assertIncompleteDecode("MESSAG");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodeFrameWithIncompleteHeader() {
|
||||
void decodeFrameWithIncompleteHeader() {
|
||||
assertIncompleteDecode("SEND\ndestination");
|
||||
assertIncompleteDecode("SEND\ndestination:");
|
||||
assertIncompleteDecode("SEND\ndestination:test");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodeFrameWithoutNullOctetTerminator() {
|
||||
void decodeFrameWithoutNullOctetTerminator() {
|
||||
assertIncompleteDecode("SEND\ndestination:test\n");
|
||||
assertIncompleteDecode("SEND\ndestination:test\n\n");
|
||||
assertIncompleteDecode("SEND\ndestination:test\n\nThe body");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodeFrameWithInsufficientContent() {
|
||||
void decodeFrameWithInsufficientContent() {
|
||||
assertIncompleteDecode("SEND\ncontent-length:23\n\nThe body of the mess");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodeFrameWithIncompleteContentType() {
|
||||
void decodeFrameWithIncompleteContentType() {
|
||||
assertIncompleteDecode("SEND\ncontent-type:text/plain;charset=U");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodeFrameWithInvalidContentType() {
|
||||
void decodeFrameWithInvalidContentType() {
|
||||
assertThatExceptionOfType(InvalidMimeTypeException.class).isThrownBy(() ->
|
||||
assertIncompleteDecode("SEND\ncontent-type:text/plain;charset=U\n\nThe body\0"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodeFrameWithIncorrectTerminator() {
|
||||
void decodeFrameWithIncorrectTerminator() {
|
||||
assertThatExceptionOfType(StompConversionException.class).isThrownBy(() ->
|
||||
decode("SEND\ncontent-length:23\n\nThe body of the message*"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodeHeartbeat() {
|
||||
void decodeHeartbeat() {
|
||||
String frame = "\n";
|
||||
|
||||
ByteBuffer buffer = ByteBuffer.wrap(frame.getBytes());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -29,13 +29,13 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
* @author Andy Wilkinson
|
||||
* @author Stephane Maldini
|
||||
*/
|
||||
public class StompEncoderTests {
|
||||
class StompEncoderTests {
|
||||
|
||||
private final StompEncoder encoder = new StompEncoder();
|
||||
|
||||
|
||||
@Test
|
||||
public void encodeFrameWithNoHeadersAndNoBody() {
|
||||
void encodeFrameWithNoHeadersAndNoBody() {
|
||||
StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.DISCONNECT);
|
||||
Message<byte[]> frame = MessageBuilder.createMessage(new byte[0], headers.getMessageHeaders());
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class StompEncoderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void encodeFrameWithHeaders() {
|
||||
void encodeFrameWithHeaders() {
|
||||
StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.CONNECT);
|
||||
headers.setAcceptVersion("1.2");
|
||||
headers.setHost("github.org");
|
||||
|
@ -55,7 +55,7 @@ public class StompEncoderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void encodeFrameWithHeadersThatShouldBeEscaped() {
|
||||
void encodeFrameWithHeadersThatShouldBeEscaped() {
|
||||
StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.DISCONNECT);
|
||||
headers.addNativeHeader("a:\r\n\\b", "alpha:bravo\r\n\\");
|
||||
Message<byte[]> frame = MessageBuilder.createMessage(new byte[0], headers.getMessageHeaders());
|
||||
|
@ -64,7 +64,7 @@ public class StompEncoderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void encodeFrameWithHeadersBody() {
|
||||
void encodeFrameWithHeadersBody() {
|
||||
StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.SEND);
|
||||
headers.addNativeHeader("a", "alpha");
|
||||
Message<byte[]> frame = MessageBuilder.createMessage(
|
||||
|
@ -74,7 +74,7 @@ public class StompEncoderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void encodeFrameWithContentLengthPresent() {
|
||||
void encodeFrameWithContentLengthPresent() {
|
||||
StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.SEND);
|
||||
headers.setContentLength(12);
|
||||
Message<byte[]> frame = MessageBuilder.createMessage(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,7 +16,6 @@
|
|||
|
||||
package org.springframework.messaging.simp.stomp;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -44,10 +43,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
* @author Rossen Stoyanchev
|
||||
* @since 4.0
|
||||
*/
|
||||
public class StompHeaderAccessorTests {
|
||||
class StompHeaderAccessorTests {
|
||||
|
||||
@Test
|
||||
public void createWithCommand() {
|
||||
void createWithCommand() {
|
||||
StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.CONNECTED);
|
||||
assertThat(accessor.getCommand()).isEqualTo(StompCommand.CONNECTED);
|
||||
|
||||
|
@ -56,7 +55,7 @@ public class StompHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void createWithSubscribeNativeHeaders() {
|
||||
void createWithSubscribeNativeHeaders() {
|
||||
MultiValueMap<String, String> extHeaders = new LinkedMultiValueMap<>();
|
||||
extHeaders.add(StompHeaderAccessor.STOMP_ID_HEADER, "s1");
|
||||
extHeaders.add(StompHeaderAccessor.STOMP_DESTINATION_HEADER, "/d");
|
||||
|
@ -70,7 +69,7 @@ public class StompHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void createWithUnsubscribeNativeHeaders() {
|
||||
void createWithUnsubscribeNativeHeaders() {
|
||||
MultiValueMap<String, String> extHeaders = new LinkedMultiValueMap<>();
|
||||
extHeaders.add(StompHeaderAccessor.STOMP_ID_HEADER, "s1");
|
||||
|
||||
|
@ -82,7 +81,7 @@ public class StompHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void createWithMessageFrameNativeHeaders() {
|
||||
void createWithMessageFrameNativeHeaders() {
|
||||
MultiValueMap<String, String> extHeaders = new LinkedMultiValueMap<>();
|
||||
extHeaders.add(StompHeaderAccessor.DESTINATION_HEADER, "/d");
|
||||
extHeaders.add(StompHeaderAccessor.STOMP_SUBSCRIPTION_HEADER, "s1");
|
||||
|
@ -96,7 +95,7 @@ public class StompHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void createWithConnectNativeHeaders() {
|
||||
void createWithConnectNativeHeaders() {
|
||||
MultiValueMap<String, String> extHeaders = new LinkedMultiValueMap<>();
|
||||
extHeaders.add(StompHeaderAccessor.STOMP_LOGIN_HEADER, "joe");
|
||||
extHeaders.add(StompHeaderAccessor.STOMP_PASSCODE_HEADER, "joe123");
|
||||
|
@ -111,12 +110,12 @@ public class StompHeaderAccessorTests {
|
|||
assertThat(headerAccessor.toString()).contains("passcode=[PROTECTED]");
|
||||
|
||||
Map<String, List<String>> output = headerAccessor.toNativeHeaderMap();
|
||||
assertThat(output.get(StompHeaderAccessor.STOMP_LOGIN_HEADER)).element(0).isEqualTo("joe");
|
||||
assertThat(output.get(StompHeaderAccessor.STOMP_PASSCODE_HEADER)).element(0).isEqualTo("PROTECTED");
|
||||
assertThat(output.get(StompHeaderAccessor.STOMP_LOGIN_HEADER)).containsExactly("joe");
|
||||
assertThat(output.get(StompHeaderAccessor.STOMP_PASSCODE_HEADER)).containsExactly("PROTECTED");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toNativeHeadersSubscribe() {
|
||||
void toNativeHeadersSubscribe() {
|
||||
StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.SUBSCRIBE);
|
||||
headers.setSubscriptionId("s1");
|
||||
headers.setDestination("/d");
|
||||
|
@ -124,23 +123,23 @@ public class StompHeaderAccessorTests {
|
|||
Map<String, List<String>> actual = headers.toNativeHeaderMap();
|
||||
|
||||
assertThat(actual).hasSize(2);
|
||||
assertThat(actual.get(StompHeaderAccessor.STOMP_ID_HEADER)).element(0).isEqualTo("s1");
|
||||
assertThat(actual.get(StompHeaderAccessor.STOMP_DESTINATION_HEADER)).element(0).isEqualTo("/d");
|
||||
assertThat(actual.get(StompHeaderAccessor.STOMP_ID_HEADER)).containsExactly("s1");
|
||||
assertThat(actual.get(StompHeaderAccessor.STOMP_DESTINATION_HEADER)).containsExactly("/d");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toNativeHeadersUnsubscribe() {
|
||||
void toNativeHeadersUnsubscribe() {
|
||||
StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.UNSUBSCRIBE);
|
||||
headers.setSubscriptionId("s1");
|
||||
|
||||
Map<String, List<String>> actual = headers.toNativeHeaderMap();
|
||||
|
||||
assertThat(actual).hasSize(1);
|
||||
assertThat(actual.get(StompHeaderAccessor.STOMP_ID_HEADER)).element(0).isEqualTo("s1");
|
||||
assertThat(actual.get(StompHeaderAccessor.STOMP_ID_HEADER)).containsExactly("s1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toNativeHeadersMessageFrame() {
|
||||
void toNativeHeadersMessageFrame() {
|
||||
StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.MESSAGE);
|
||||
headers.setSubscriptionId("s1");
|
||||
headers.setDestination("/d");
|
||||
|
@ -150,14 +149,14 @@ public class StompHeaderAccessorTests {
|
|||
Map<String, List<String>> actual = headers.toNativeHeaderMap();
|
||||
|
||||
assertThat(actual.size()).as(actual.toString()).isEqualTo(4);
|
||||
assertThat(actual.get(StompHeaderAccessor.STOMP_SUBSCRIPTION_HEADER)).element(0).isEqualTo("s1");
|
||||
assertThat(actual.get(StompHeaderAccessor.STOMP_DESTINATION_HEADER)).element(0).isEqualTo("/d");
|
||||
assertThat(actual.get(StompHeaderAccessor.STOMP_CONTENT_TYPE_HEADER)).element(0).isEqualTo("application/json");
|
||||
assertThat(actual.get(StompHeaderAccessor.STOMP_MESSAGE_ID_HEADER)).element(0).as("message-id was not created").isNotNull();
|
||||
assertThat(actual.get(StompHeaderAccessor.STOMP_SUBSCRIPTION_HEADER)).containsExactly("s1");
|
||||
assertThat(actual.get(StompHeaderAccessor.STOMP_DESTINATION_HEADER)).containsExactly("/d");
|
||||
assertThat(actual.get(StompHeaderAccessor.STOMP_CONTENT_TYPE_HEADER)).containsExactly("application/json");
|
||||
assertThat(actual.get(StompHeaderAccessor.STOMP_MESSAGE_ID_HEADER)).singleElement().as("message-id was not created").isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toNativeHeadersContentType() {
|
||||
void toNativeHeadersContentType() {
|
||||
SimpMessageHeaderAccessor simpHeaderAccessor = SimpMessageHeaderAccessor.create();
|
||||
simpHeaderAccessor.setContentType(MimeType.valueOf("application/atom+xml"));
|
||||
Message<byte[]> message = MessageBuilder.createMessage(new byte[0], simpHeaderAccessor.getMessageHeaders());
|
||||
|
@ -165,11 +164,11 @@ public class StompHeaderAccessorTests {
|
|||
StompHeaderAccessor stompHeaderAccessor = StompHeaderAccessor.wrap(message);
|
||||
Map<String, List<String>> map = stompHeaderAccessor.toNativeHeaderMap();
|
||||
|
||||
assertThat(map.get(StompHeaderAccessor.STOMP_CONTENT_TYPE_HEADER)).element(0).isEqualTo("application/atom+xml");
|
||||
assertThat(map.get(StompHeaderAccessor.STOMP_CONTENT_TYPE_HEADER)).containsExactly("application/atom+xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void encodeConnectWithLoginAndPasscode() throws UnsupportedEncodingException {
|
||||
void encodeConnectWithLoginAndPasscode() {
|
||||
MultiValueMap<String, String> extHeaders = new LinkedMultiValueMap<>();
|
||||
extHeaders.add(StompHeaderAccessor.STOMP_LOGIN_HEADER, "joe");
|
||||
extHeaders.add(StompHeaderAccessor.STOMP_PASSCODE_HEADER, "joe123");
|
||||
|
@ -178,11 +177,11 @@ public class StompHeaderAccessorTests {
|
|||
Message<byte[]> message = MessageBuilder.createMessage(new byte[0], headerAccessor.getMessageHeaders());
|
||||
byte[] bytes = new StompEncoder().encode(message);
|
||||
|
||||
assertThat(new String(bytes, "UTF-8")).isEqualTo("CONNECT\nlogin:joe\npasscode:joe123\n\n\0");
|
||||
assertThat(new String(bytes, StandardCharsets.UTF_8)).isEqualTo("CONNECT\nlogin:joe\npasscode:joe123\n\n\0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void modifyCustomNativeHeader() {
|
||||
void modifyCustomNativeHeader() {
|
||||
MultiValueMap<String, String> extHeaders = new LinkedMultiValueMap<>();
|
||||
extHeaders.add(StompHeaderAccessor.STOMP_ID_HEADER, "s1");
|
||||
extHeaders.add(StompHeaderAccessor.STOMP_DESTINATION_HEADER, "/d");
|
||||
|
@ -195,13 +194,13 @@ public class StompHeaderAccessorTests {
|
|||
Map<String, List<String>> actual = headers.toNativeHeaderMap();
|
||||
assertThat(actual).hasSize(3);
|
||||
|
||||
assertThat(actual.get(StompHeaderAccessor.STOMP_ID_HEADER)).element(0).isEqualTo("s1");
|
||||
assertThat(actual.get(StompHeaderAccessor.STOMP_DESTINATION_HEADER)).element(0).isEqualTo("/d");
|
||||
assertThat(actual.get(StompHeaderAccessor.STOMP_ID_HEADER)).containsExactly("s1");
|
||||
assertThat(actual.get(StompHeaderAccessor.STOMP_DESTINATION_HEADER)).containsExactly("/d");
|
||||
assertThat(actual.get("accountId")).element(0).as("abc123").isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void messageIdAndTimestampDefaultBehavior() {
|
||||
void messageIdAndTimestampDefaultBehavior() {
|
||||
StompHeaderAccessor headerAccessor = StompHeaderAccessor.create(StompCommand.SEND);
|
||||
MessageHeaders headers = headerAccessor.getMessageHeaders();
|
||||
|
||||
|
@ -210,7 +209,7 @@ public class StompHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void messageIdAndTimestampEnabled() {
|
||||
void messageIdAndTimestampEnabled() {
|
||||
IdTimestampMessageHeaderInitializer headerInitializer = new IdTimestampMessageHeaderInitializer();
|
||||
headerInitializer.setIdGenerator(new AlternativeJdkIdGenerator());
|
||||
headerInitializer.setEnableTimestamp(true);
|
||||
|
@ -223,7 +222,7 @@ public class StompHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getAccessor() {
|
||||
void getAccessor() {
|
||||
StompHeaderAccessor headerAccessor = StompHeaderAccessor.create(StompCommand.CONNECT);
|
||||
Message<byte[]> message = MessageBuilder.createMessage(new byte[0], headerAccessor.getMessageHeaders());
|
||||
|
||||
|
@ -231,7 +230,7 @@ public class StompHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getShortLogMessage() {
|
||||
void getShortLogMessage() {
|
||||
StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.SEND);
|
||||
accessor.setDestination("/foo");
|
||||
accessor.setContentType(MimeTypeUtils.APPLICATION_JSON);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -38,7 +38,7 @@ import static org.mockito.Mockito.mock;
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class DefaultUserDestinationResolverTests {
|
||||
class DefaultUserDestinationResolverTests {
|
||||
|
||||
private SimpUserRegistry registry = mock();
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class DefaultUserDestinationResolverTests {
|
|||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
void setup() {
|
||||
TestSimpUser simpUser = new TestSimpUser("joe");
|
||||
simpUser.addSessions(new TestSimpSession("123"));
|
||||
|
||||
|
@ -54,7 +54,7 @@ public class DefaultUserDestinationResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void handleSubscribe() {
|
||||
void handleSubscribe() {
|
||||
TestPrincipal user = new TestPrincipal("joe");
|
||||
String sourceDestination = "/user/queue/foo";
|
||||
|
||||
|
@ -62,8 +62,7 @@ public class DefaultUserDestinationResolverTests {
|
|||
UserDestinationResult actual = this.resolver.resolveDestination(message);
|
||||
|
||||
assertThat(actual.getSourceDestination()).isEqualTo(sourceDestination);
|
||||
assertThat(actual.getTargetDestinations()).hasSize(1);
|
||||
assertThat(actual.getTargetDestinations()).element(0).isEqualTo("/queue/foo-user123");
|
||||
assertThat(actual.getTargetDestinations()).containsExactly("/queue/foo-user123");
|
||||
assertThat(actual.getSubscribeDestination()).isEqualTo(sourceDestination);
|
||||
assertThat(actual.getUser()).isEqualTo(user.getName());
|
||||
}
|
||||
|
@ -77,8 +76,7 @@ public class DefaultUserDestinationResolverTests {
|
|||
Message<?> message = createMessage(SimpMessageType.SUBSCRIBE, user, "123", destination);
|
||||
UserDestinationResult actual = this.resolver.resolveDestination(message);
|
||||
|
||||
assertThat(actual.getTargetDestinations()).hasSize(1);
|
||||
assertThat(actual.getTargetDestinations()).element(0).isEqualTo("jms.queue.call-user123");
|
||||
assertThat(actual.getTargetDestinations()).containsExactly("jms.queue.call-user123");
|
||||
assertThat(actual.getSubscribeDestination()).isEqualTo(destination);
|
||||
}
|
||||
|
||||
|
@ -93,19 +91,17 @@ public class DefaultUserDestinationResolverTests {
|
|||
Message<?> message = createMessage(SimpMessageType.SUBSCRIBE, user, "456", "/user/queue/foo");
|
||||
UserDestinationResult actual = this.resolver.resolveDestination(message);
|
||||
|
||||
assertThat(actual.getTargetDestinations()).hasSize(1);
|
||||
assertThat(actual.getTargetDestinations()).element(0).isEqualTo("/queue/foo-user456");
|
||||
assertThat(actual.getTargetDestinations()).containsExactly("/queue/foo-user456");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleSubscribeNoUser() {
|
||||
void handleSubscribeNoUser() {
|
||||
String sourceDestination = "/user/queue/foo";
|
||||
Message<?> message = createMessage(SimpMessageType.SUBSCRIBE, null, "123", sourceDestination);
|
||||
UserDestinationResult actual = this.resolver.resolveDestination(message);
|
||||
|
||||
assertThat(actual.getSourceDestination()).isEqualTo(sourceDestination);
|
||||
assertThat(actual.getTargetDestinations()).hasSize(1);
|
||||
assertThat(actual.getTargetDestinations()).element(0).isEqualTo(("/queue/foo-user" + "123"));
|
||||
assertThat(actual.getTargetDestinations()).containsExactly("/queue/foo-user" + "123");
|
||||
assertThat(actual.getSubscribeDestination()).isEqualTo(sourceDestination);
|
||||
assertThat(actual.getUser()).isNull();
|
||||
}
|
||||
|
@ -120,25 +116,23 @@ public class DefaultUserDestinationResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void handleUnsubscribe() {
|
||||
void handleUnsubscribe() {
|
||||
TestPrincipal user = new TestPrincipal("joe");
|
||||
Message<?> message = createMessage(SimpMessageType.UNSUBSCRIBE, user, "123", "/user/queue/foo");
|
||||
UserDestinationResult actual = this.resolver.resolveDestination(message);
|
||||
|
||||
assertThat(actual.getTargetDestinations()).hasSize(1);
|
||||
assertThat(actual.getTargetDestinations()).element(0).isEqualTo("/queue/foo-user123");
|
||||
assertThat(actual.getTargetDestinations()).containsExactly("/queue/foo-user123");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleMessage() {
|
||||
void handleMessage() {
|
||||
TestPrincipal user = new TestPrincipal("joe");
|
||||
String sourceDestination = "/user/joe/queue/foo";
|
||||
Message<?> message = createMessage(SimpMessageType.MESSAGE, user, "123", sourceDestination);
|
||||
UserDestinationResult actual = this.resolver.resolveDestination(message);
|
||||
|
||||
assertThat(actual.getSourceDestination()).isEqualTo(sourceDestination);
|
||||
assertThat(actual.getTargetDestinations()).hasSize(1);
|
||||
assertThat(actual.getTargetDestinations()).element(0).isEqualTo("/queue/foo-user123");
|
||||
assertThat(actual.getTargetDestinations()).containsExactly("/queue/foo-user123");
|
||||
assertThat(actual.getSubscribeDestination()).isEqualTo("/user/queue/foo");
|
||||
assertThat(actual.getUser()).isEqualTo(user.getName());
|
||||
}
|
||||
|
@ -152,8 +146,7 @@ public class DefaultUserDestinationResolverTests {
|
|||
Message<?> message = createMessage(SimpMessageType.MESSAGE, user, "123", destination);
|
||||
UserDestinationResult actual = this.resolver.resolveDestination(message);
|
||||
|
||||
assertThat(actual.getTargetDestinations()).hasSize(1);
|
||||
assertThat(actual.getTargetDestinations()).element(0).isEqualTo("jms.queue.call-user123");
|
||||
assertThat(actual.getTargetDestinations()).containsExactly("jms.queue.call-user123");
|
||||
assertThat(actual.getSubscribeDestination()).isEqualTo("/user/jms.queue.call");
|
||||
}
|
||||
|
||||
|
@ -172,14 +165,13 @@ public class DefaultUserDestinationResolverTests {
|
|||
UserDestinationResult actual = this.resolver.resolveDestination(message);
|
||||
|
||||
assertThat(actual.getSourceDestination()).isEqualTo(sourceDestination);
|
||||
assertThat(actual.getTargetDestinations()).hasSize(1);
|
||||
assertThat(actual.getTargetDestinations()).element(0).isEqualTo("/queue/foo-user456");
|
||||
assertThat(actual.getTargetDestinations()).containsExactly("/queue/foo-user456");
|
||||
assertThat(actual.getSubscribeDestination()).isEqualTo("/user/queue/foo");
|
||||
assertThat(actual.getUser()).isEqualTo(otherUser.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleMessageEncodedUserName() {
|
||||
void handleMessageEncodedUserName() {
|
||||
String userName = "https://joe.openid.example.org/";
|
||||
|
||||
TestSimpUser simpUser = new TestSimpUser(userName);
|
||||
|
@ -191,25 +183,23 @@ public class DefaultUserDestinationResolverTests {
|
|||
Message<?> message = createMessage(SimpMessageType.MESSAGE, new TestPrincipal("joe"), null, destination);
|
||||
UserDestinationResult actual = this.resolver.resolveDestination(message);
|
||||
|
||||
assertThat(actual.getTargetDestinations()).hasSize(1);
|
||||
assertThat(actual.getTargetDestinations()).element(0).isEqualTo("/queue/foo-useropenid123");
|
||||
assertThat(actual.getTargetDestinations()).containsExactly("/queue/foo-useropenid123");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleMessageWithNoUser() {
|
||||
void handleMessageWithNoUser() {
|
||||
String sourceDestination = "/user/" + "123" + "/queue/foo";
|
||||
Message<?> message = createMessage(SimpMessageType.MESSAGE, null, "123", sourceDestination);
|
||||
UserDestinationResult actual = this.resolver.resolveDestination(message);
|
||||
|
||||
assertThat(actual.getSourceDestination()).isEqualTo(sourceDestination);
|
||||
assertThat(actual.getTargetDestinations()).hasSize(1);
|
||||
assertThat(actual.getTargetDestinations()).element(0).isEqualTo("/queue/foo-user123");
|
||||
assertThat(actual.getTargetDestinations()).containsExactly("/queue/foo-user123");
|
||||
assertThat(actual.getSubscribeDestination()).isEqualTo("/user/queue/foo");
|
||||
assertThat(actual.getUser()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ignoreMessage() {
|
||||
void ignoreMessage() {
|
||||
|
||||
// no destination
|
||||
TestPrincipal user = new TestPrincipal("joe");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -65,7 +65,7 @@ class UserRegistryMessageHandlerTests {
|
|||
|
||||
|
||||
@BeforeEach
|
||||
void setUp() throws Exception {
|
||||
void setUp() {
|
||||
SimpMessagingTemplate brokerTemplate = new SimpMessagingTemplate(this.brokerChannel);
|
||||
brokerTemplate.setMessageConverter(this.converter);
|
||||
|
||||
|
@ -74,14 +74,14 @@ class UserRegistryMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
void brokerAvailableEvent() throws Exception {
|
||||
void brokerAvailableEvent() {
|
||||
Runnable runnable = getUserRegistryTask();
|
||||
assertThat(runnable).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
void brokerUnavailableEvent() throws Exception {
|
||||
void brokerUnavailableEvent() {
|
||||
ScheduledFuture future = mock();
|
||||
given(this.taskScheduler.scheduleWithFixedDelay(any(Runnable.class), any(Duration.class))).willReturn(future);
|
||||
|
||||
|
@ -96,7 +96,7 @@ class UserRegistryMessageHandlerTests {
|
|||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
void broadcastRegistry() throws Exception {
|
||||
void broadcastRegistry() {
|
||||
given(this.brokerChannel.send(any())).willReturn(true);
|
||||
|
||||
TestSimpUser simpUser1 = new TestSimpUser("joe");
|
||||
|
@ -126,7 +126,7 @@ class UserRegistryMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
void handleMessage() throws Exception {
|
||||
void handleMessage() {
|
||||
TestSimpUser simpUser1 = new TestSimpUser("joe");
|
||||
TestSimpUser simpUser2 = new TestSimpUser("jane");
|
||||
|
||||
|
@ -149,7 +149,7 @@ class UserRegistryMessageHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
void handleMessageFromOwnBroadcast() throws Exception {
|
||||
void handleMessageFromOwnBroadcast() {
|
||||
TestSimpUser simpUser = new TestSimpUser("joe");
|
||||
simpUser.addSessions(new TestSimpSession("123"));
|
||||
given(this.localRegistry.getUserCount()).willReturn(1);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -37,7 +37,7 @@ import static org.mockito.Mockito.mock;
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class ChannelInterceptorTests {
|
||||
class ChannelInterceptorTests {
|
||||
|
||||
private ExecutorSubscribableChannel channel;
|
||||
|
||||
|
@ -45,7 +45,7 @@ public class ChannelInterceptorTests {
|
|||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
void setup() {
|
||||
this.channel = new ExecutorSubscribableChannel();
|
||||
this.messageHandler = new TestMessageHandler();
|
||||
this.channel.subscribe(this.messageHandler);
|
||||
|
@ -53,7 +53,7 @@ public class ChannelInterceptorTests {
|
|||
|
||||
|
||||
@Test
|
||||
public void preSendInterceptorReturningModifiedMessage() {
|
||||
void preSendInterceptorReturningModifiedMessage() {
|
||||
Message<?> expected = mock();
|
||||
PreSendInterceptor interceptor = new PreSendInterceptor();
|
||||
interceptor.setMessageToReturn(expected);
|
||||
|
@ -69,7 +69,7 @@ public class ChannelInterceptorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void preSendInterceptorReturningNull() {
|
||||
void preSendInterceptorReturningNull() {
|
||||
PreSendInterceptor interceptor1 = new PreSendInterceptor();
|
||||
NullReturningPreSendInterceptor interceptor2 = new NullReturningPreSendInterceptor();
|
||||
this.channel.addInterceptor(interceptor1);
|
||||
|
@ -85,7 +85,7 @@ public class ChannelInterceptorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void postSendInterceptorMessageWasSent() {
|
||||
void postSendInterceptorMessageWasSent() {
|
||||
final AtomicBoolean preSendInvoked = new AtomicBoolean();
|
||||
final AtomicBoolean completionInvoked = new AtomicBoolean();
|
||||
this.channel.addInterceptor(new ChannelInterceptor() {
|
||||
|
@ -112,7 +112,7 @@ public class ChannelInterceptorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void postSendInterceptorMessageWasNotSent() {
|
||||
void postSendInterceptorMessageWasNotSent() {
|
||||
final AbstractMessageChannel testChannel = new AbstractMessageChannel() {
|
||||
@Override
|
||||
protected boolean sendInternal(Message<?> message, long timeout) {
|
||||
|
@ -145,7 +145,7 @@ public class ChannelInterceptorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void afterCompletionWithSendException() {
|
||||
void afterCompletionWithSendException() {
|
||||
final AbstractMessageChannel testChannel = new AbstractMessageChannel() {
|
||||
@Override
|
||||
protected boolean sendInternal(Message<?> message, long timeout) {
|
||||
|
@ -167,7 +167,7 @@ public class ChannelInterceptorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void afterCompletionWithPreSendException() {
|
||||
void afterCompletionWithPreSendException() {
|
||||
PreSendInterceptor interceptor1 = new PreSendInterceptor();
|
||||
PreSendInterceptor interceptor2 = new PreSendInterceptor();
|
||||
interceptor2.setExceptionToRaise(new RuntimeException("Simulated exception"));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -25,10 +25,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
* @author Gary Russell
|
||||
* @since 5.0
|
||||
*/
|
||||
public class ErrorMessageTests {
|
||||
class ErrorMessageTests {
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
void testToString() {
|
||||
ErrorMessage em = new ErrorMessage(new RuntimeException("foo"));
|
||||
String emString = em.toString();
|
||||
assertThat(emString).doesNotContain("original");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -63,14 +63,14 @@ public class ExecutorSubscribableChannelTests {
|
|||
|
||||
|
||||
@Test
|
||||
public void messageMustNotBeNull() {
|
||||
void messageMustNotBeNull() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
this.channel.send(null))
|
||||
.withMessageContaining("Message must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sendWithoutExecutor() {
|
||||
void sendWithoutExecutor() {
|
||||
BeforeHandleInterceptor interceptor = new BeforeHandleInterceptor();
|
||||
this.channel.addInterceptor(interceptor);
|
||||
this.channel.subscribe(this.handler);
|
||||
|
@ -81,7 +81,7 @@ public class ExecutorSubscribableChannelTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void sendWithExecutor() {
|
||||
void sendWithExecutor() {
|
||||
BeforeHandleInterceptor interceptor = new BeforeHandleInterceptor();
|
||||
TaskExecutor executor = mock();
|
||||
ExecutorSubscribableChannel testChannel = new ExecutorSubscribableChannel(executor);
|
||||
|
@ -97,7 +97,7 @@ public class ExecutorSubscribableChannelTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void subscribeTwice() {
|
||||
void subscribeTwice() {
|
||||
assertThat(this.channel.subscribe(this.handler)).isTrue();
|
||||
assertThat(this.channel.subscribe(this.handler)).isFalse();
|
||||
this.channel.send(this.message);
|
||||
|
@ -105,7 +105,7 @@ public class ExecutorSubscribableChannelTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void unsubscribeTwice() {
|
||||
void unsubscribeTwice() {
|
||||
this.channel.subscribe(this.handler);
|
||||
assertThat(this.channel.unsubscribe(this.handler)).isTrue();
|
||||
assertThat(this.channel.unsubscribe(this.handler)).isFalse();
|
||||
|
@ -114,7 +114,7 @@ public class ExecutorSubscribableChannelTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void failurePropagates() {
|
||||
void failurePropagates() {
|
||||
RuntimeException ex = new RuntimeException();
|
||||
willThrow(ex).given(this.handler).handleMessage(this.message);
|
||||
MessageHandler secondHandler = mock();
|
||||
|
@ -130,7 +130,7 @@ public class ExecutorSubscribableChannelTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void concurrentModification() {
|
||||
void concurrentModification() {
|
||||
this.channel.subscribe(message1 -> channel.unsubscribe(handler));
|
||||
this.channel.subscribe(this.handler);
|
||||
this.channel.send(this.message);
|
||||
|
@ -138,7 +138,7 @@ public class ExecutorSubscribableChannelTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void interceptorWithModifiedMessage() {
|
||||
void interceptorWithModifiedMessage() {
|
||||
Message<?> expected = mock();
|
||||
BeforeHandleInterceptor interceptor = new BeforeHandleInterceptor();
|
||||
interceptor.setMessageToReturn(expected);
|
||||
|
@ -151,7 +151,7 @@ public class ExecutorSubscribableChannelTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void interceptorWithNull() {
|
||||
void interceptorWithNull() {
|
||||
BeforeHandleInterceptor interceptor1 = new BeforeHandleInterceptor();
|
||||
NullReturningBeforeHandleInterceptor interceptor2 = new NullReturningBeforeHandleInterceptor();
|
||||
this.channel.addInterceptor(interceptor1);
|
||||
|
@ -165,7 +165,7 @@ public class ExecutorSubscribableChannelTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void interceptorWithException() {
|
||||
void interceptorWithException() {
|
||||
IllegalStateException expected = new IllegalStateException("Fake exception");
|
||||
willThrow(expected).given(this.handler).handleMessage(this.message);
|
||||
BeforeHandleInterceptor interceptor = new BeforeHandleInterceptor();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -150,28 +150,28 @@ class MessageBuilderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
void notModifiedSameMessage() throws Exception {
|
||||
void notModifiedSameMessage() {
|
||||
Message<?> original = MessageBuilder.withPayload("foo").build();
|
||||
Message<?> result = MessageBuilder.fromMessage(original).build();
|
||||
assertThat(result).isEqualTo(original);
|
||||
}
|
||||
|
||||
@Test
|
||||
void containsHeaderNotModifiedSameMessage() throws Exception {
|
||||
void containsHeaderNotModifiedSameMessage() {
|
||||
Message<?> original = MessageBuilder.withPayload("foo").setHeader("bar", 42).build();
|
||||
Message<?> result = MessageBuilder.fromMessage(original).build();
|
||||
assertThat(result).isEqualTo(original);
|
||||
}
|
||||
|
||||
@Test
|
||||
void sameHeaderValueAddedNotModifiedSameMessage() throws Exception {
|
||||
void sameHeaderValueAddedNotModifiedSameMessage() {
|
||||
Message<?> original = MessageBuilder.withPayload("foo").setHeader("bar", 42).build();
|
||||
Message<?> result = MessageBuilder.fromMessage(original).setHeader("bar", 42).build();
|
||||
assertThat(result).isEqualTo(original);
|
||||
}
|
||||
|
||||
@Test
|
||||
void copySameHeaderValuesNotModifiedSameMessage() throws Exception {
|
||||
void copySameHeaderValuesNotModifiedSameMessage() {
|
||||
Date current = new Date();
|
||||
Map<String, Object> originalHeaders = new HashMap<>();
|
||||
originalHeaders.put("b", "xyz");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -39,16 +39,16 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
|||
* @author Sebastien Deleuze
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class MessageHeaderAccessorTests {
|
||||
class MessageHeaderAccessorTests {
|
||||
|
||||
@Test
|
||||
public void newEmptyHeaders() {
|
||||
void newEmptyHeaders() {
|
||||
MessageHeaderAccessor accessor = new MessageHeaderAccessor();
|
||||
assertThat(accessor.toMap()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void existingHeaders() throws InterruptedException {
|
||||
void existingHeaders() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("foo", "bar");
|
||||
map.put("bar", "baz");
|
||||
|
@ -63,7 +63,7 @@ public class MessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void existingHeadersModification() throws InterruptedException {
|
||||
void existingHeadersModification() throws InterruptedException {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("foo", "bar");
|
||||
map.put("bar", "baz");
|
||||
|
@ -82,7 +82,7 @@ public class MessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveHeader() {
|
||||
void testRemoveHeader() {
|
||||
Message<?> message = new GenericMessage<>("payload", Collections.singletonMap("foo", "bar"));
|
||||
MessageHeaderAccessor accessor = new MessageHeaderAccessor(message);
|
||||
accessor.removeHeader("foo");
|
||||
|
@ -91,7 +91,7 @@ public class MessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveHeaderEvenIfNull() {
|
||||
void testRemoveHeaderEvenIfNull() {
|
||||
Message<?> message = new GenericMessage<>("payload", Collections.singletonMap("foo", null));
|
||||
MessageHeaderAccessor accessor = new MessageHeaderAccessor(message);
|
||||
accessor.removeHeader("foo");
|
||||
|
@ -100,7 +100,7 @@ public class MessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void removeHeaders() {
|
||||
void removeHeaders() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("foo", "bar");
|
||||
map.put("bar", "baz");
|
||||
|
@ -116,7 +116,7 @@ public class MessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void copyHeaders() {
|
||||
void copyHeaders() {
|
||||
Map<String, Object> map1 = new HashMap<>();
|
||||
map1.put("foo", "bar");
|
||||
GenericMessage<String> message = new GenericMessage<>("payload", map1);
|
||||
|
@ -134,7 +134,7 @@ public class MessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void copyHeadersIfAbsent() {
|
||||
void copyHeadersIfAbsent() {
|
||||
Map<String, Object> map1 = new HashMap<>();
|
||||
map1.put("foo", "bar");
|
||||
GenericMessage<String> message = new GenericMessage<>("payload", map1);
|
||||
|
@ -152,7 +152,7 @@ public class MessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void copyHeadersFromNullMap() {
|
||||
void copyHeadersFromNullMap() {
|
||||
MessageHeaderAccessor headers = new MessageHeaderAccessor();
|
||||
headers.copyHeaders(null);
|
||||
headers.copyHeadersIfAbsent(null);
|
||||
|
@ -161,7 +161,7 @@ public class MessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void toMap() {
|
||||
void toMap() {
|
||||
MessageHeaderAccessor accessor = new MessageHeaderAccessor();
|
||||
|
||||
accessor.setHeader("foo", "bar1");
|
||||
|
@ -183,7 +183,7 @@ public class MessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void leaveMutable() {
|
||||
void leaveMutable() {
|
||||
MessageHeaderAccessor accessor = new MessageHeaderAccessor();
|
||||
accessor.setHeader("foo", "bar");
|
||||
accessor.setLeaveMutable(true);
|
||||
|
@ -197,7 +197,7 @@ public class MessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void leaveMutableDefaultBehavior() {
|
||||
void leaveMutableDefaultBehavior() {
|
||||
MessageHeaderAccessor accessor = new MessageHeaderAccessor();
|
||||
accessor.setHeader("foo", "bar");
|
||||
MessageHeaders headers = accessor.getMessageHeaders();
|
||||
|
@ -216,14 +216,14 @@ public class MessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getAccessor() {
|
||||
void getAccessor() {
|
||||
MessageHeaderAccessor expected = new MessageHeaderAccessor();
|
||||
Message<?> message = MessageBuilder.createMessage("payload", expected.getMessageHeaders());
|
||||
assertThat(MessageHeaderAccessor.getAccessor(message, MessageHeaderAccessor.class)).isSameAs(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMutableAccessorSameInstance() {
|
||||
void getMutableAccessorSameInstance() {
|
||||
TestMessageHeaderAccessor expected = new TestMessageHeaderAccessor();
|
||||
expected.setLeaveMutable(true);
|
||||
Message<?> message = MessageBuilder.createMessage("payload", expected.getMessageHeaders());
|
||||
|
@ -235,7 +235,7 @@ public class MessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getMutableAccessorNewInstance() {
|
||||
void getMutableAccessorNewInstance() {
|
||||
Message<?> message = MessageBuilder.withPayload("payload").build();
|
||||
|
||||
MessageHeaderAccessor actual = MessageHeaderAccessor.getMutableAccessor(message);
|
||||
|
@ -244,7 +244,7 @@ public class MessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getMutableAccessorNewInstanceMatchingType() {
|
||||
void getMutableAccessorNewInstanceMatchingType() {
|
||||
TestMessageHeaderAccessor expected = new TestMessageHeaderAccessor();
|
||||
Message<?> message = MessageBuilder.createMessage("payload", expected.getMessageHeaders());
|
||||
|
||||
|
@ -255,20 +255,20 @@ public class MessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void timestampEnabled() {
|
||||
void timestampEnabled() {
|
||||
MessageHeaderAccessor accessor = new MessageHeaderAccessor();
|
||||
accessor.setEnableTimestamp(true);
|
||||
assertThat(accessor.getMessageHeaders().getTimestamp()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void timestampDefaultBehavior() {
|
||||
void timestampDefaultBehavior() {
|
||||
MessageHeaderAccessor accessor = new MessageHeaderAccessor();
|
||||
assertThat(accessor.getMessageHeaders().getTimestamp()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void idGeneratorCustom() {
|
||||
void idGeneratorCustom() {
|
||||
final UUID id = new UUID(0L, 23L);
|
||||
MessageHeaderAccessor accessor = new MessageHeaderAccessor();
|
||||
accessor.setIdGenerator(() -> id);
|
||||
|
@ -276,14 +276,14 @@ public class MessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void idGeneratorDefaultBehavior() {
|
||||
void idGeneratorDefaultBehavior() {
|
||||
MessageHeaderAccessor accessor = new MessageHeaderAccessor();
|
||||
assertThat(accessor.getMessageHeaders().getId()).isNotNull();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void idTimestampWithMutableHeaders() {
|
||||
void idTimestampWithMutableHeaders() {
|
||||
MessageHeaderAccessor accessor = new MessageHeaderAccessor();
|
||||
accessor.setIdGenerator(() -> MessageHeaders.ID_VALUE_NONE);
|
||||
accessor.setEnableTimestamp(false);
|
||||
|
@ -303,7 +303,7 @@ public class MessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getShortLogMessagePayload() {
|
||||
void getShortLogMessagePayload() {
|
||||
MessageHeaderAccessor accessor = new MessageHeaderAccessor();
|
||||
accessor.setContentType(MimeTypeUtils.TEXT_PLAIN);
|
||||
|
||||
|
@ -319,7 +319,7 @@ public class MessageHeaderAccessorTests {
|
|||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("a".repeat(80));
|
||||
final String payload = sb.toString() + " > 80";
|
||||
final String payload = sb + " > 80";
|
||||
|
||||
String actual = accessor.getShortLogMessage(payload);
|
||||
assertThat(actual).isEqualTo("headers={contentType=text/plain} payload=" + sb + "...(truncated)");
|
||||
|
@ -337,7 +337,7 @@ public class MessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getDetailedLogMessagePayload() {
|
||||
void getDetailedLogMessagePayload() {
|
||||
MessageHeaderAccessor accessor = new MessageHeaderAccessor();
|
||||
accessor.setContentType(MimeTypeUtils.TEXT_PLAIN);
|
||||
|
||||
|
@ -371,7 +371,7 @@ public class MessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void serializeMutableHeaders() throws Exception {
|
||||
void serializeMutableHeaders() throws Exception {
|
||||
Map<String, Object> headers = new HashMap<>();
|
||||
headers.put("foo", "bar");
|
||||
Message<String> message = new GenericMessage<>("test", headers);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -36,10 +36,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class NativeMessageHeaderAccessorTests {
|
||||
class NativeMessageHeaderAccessorTests {
|
||||
|
||||
@Test
|
||||
public void createFromNativeHeaderMap() {
|
||||
void createFromNativeHeaderMap() {
|
||||
MultiValueMap<String, String> inputNativeHeaders = new LinkedMultiValueMap<>();
|
||||
inputNativeHeaders.add("foo", "bar");
|
||||
inputNativeHeaders.add("bar", "baz");
|
||||
|
@ -54,7 +54,7 @@ public class NativeMessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void createFromMessage() {
|
||||
void createFromMessage() {
|
||||
MultiValueMap<String, String> inputNativeHeaders = new LinkedMultiValueMap<>();
|
||||
inputNativeHeaders.add("foo", "bar");
|
||||
inputNativeHeaders.add("bar", "baz");
|
||||
|
@ -75,7 +75,7 @@ public class NativeMessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void createFromMessageNull() {
|
||||
void createFromMessageNull() {
|
||||
NativeMessageHeaderAccessor headerAccessor = new NativeMessageHeaderAccessor((Message<?>) null);
|
||||
|
||||
Map<String, Object> actual = headerAccessor.toMap();
|
||||
|
@ -86,7 +86,7 @@ public class NativeMessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void createFromMessageAndModify() {
|
||||
void createFromMessageAndModify() {
|
||||
|
||||
MultiValueMap<String, String> inputNativeHeaders = new LinkedMultiValueMap<>();
|
||||
inputNativeHeaders.add("foo", "bar");
|
||||
|
@ -117,7 +117,7 @@ public class NativeMessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void setNativeHeader() {
|
||||
void setNativeHeader() {
|
||||
MultiValueMap<String, String> nativeHeaders = new LinkedMultiValueMap<>();
|
||||
nativeHeaders.add("foo", "bar");
|
||||
|
||||
|
@ -128,7 +128,7 @@ public class NativeMessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void setNativeHeaderNullValue() {
|
||||
void setNativeHeaderNullValue() {
|
||||
MultiValueMap<String, String> nativeHeaders = new LinkedMultiValueMap<>();
|
||||
nativeHeaders.add("foo", "bar");
|
||||
|
||||
|
@ -139,7 +139,7 @@ public class NativeMessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void setNativeHeaderLazyInit() {
|
||||
void setNativeHeaderLazyInit() {
|
||||
NativeMessageHeaderAccessor headerAccessor = new NativeMessageHeaderAccessor();
|
||||
headerAccessor.setNativeHeader("foo", "baz");
|
||||
|
||||
|
@ -147,7 +147,7 @@ public class NativeMessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void setNativeHeaderLazyInitNullValue() {
|
||||
void setNativeHeaderLazyInitNullValue() {
|
||||
NativeMessageHeaderAccessor headerAccessor = new NativeMessageHeaderAccessor();
|
||||
headerAccessor.setNativeHeader("foo", null);
|
||||
|
||||
|
@ -156,7 +156,7 @@ public class NativeMessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void setNativeHeaderImmutable() {
|
||||
void setNativeHeaderImmutable() {
|
||||
NativeMessageHeaderAccessor headerAccessor = new NativeMessageHeaderAccessor();
|
||||
headerAccessor.setNativeHeader("foo", "bar");
|
||||
headerAccessor.setImmutable();
|
||||
|
@ -167,7 +167,7 @@ public class NativeMessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void addNativeHeader() {
|
||||
void addNativeHeader() {
|
||||
MultiValueMap<String, String> nativeHeaders = new LinkedMultiValueMap<>();
|
||||
nativeHeaders.add("foo", "bar");
|
||||
|
||||
|
@ -178,7 +178,7 @@ public class NativeMessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void addNativeHeaderNullValue() {
|
||||
void addNativeHeaderNullValue() {
|
||||
MultiValueMap<String, String> nativeHeaders = new LinkedMultiValueMap<>();
|
||||
nativeHeaders.add("foo", "bar");
|
||||
|
||||
|
@ -189,7 +189,7 @@ public class NativeMessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void addNativeHeaderLazyInit() {
|
||||
void addNativeHeaderLazyInit() {
|
||||
NativeMessageHeaderAccessor headerAccessor = new NativeMessageHeaderAccessor();
|
||||
headerAccessor.addNativeHeader("foo", "bar");
|
||||
|
||||
|
@ -197,7 +197,7 @@ public class NativeMessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void addNativeHeaderLazyInitNullValue() {
|
||||
void addNativeHeaderLazyInitNullValue() {
|
||||
NativeMessageHeaderAccessor headerAccessor = new NativeMessageHeaderAccessor();
|
||||
headerAccessor.addNativeHeader("foo", null);
|
||||
|
||||
|
@ -206,7 +206,7 @@ public class NativeMessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void addNativeHeaderImmutable() {
|
||||
void addNativeHeaderImmutable() {
|
||||
NativeMessageHeaderAccessor headerAccessor = new NativeMessageHeaderAccessor();
|
||||
headerAccessor.addNativeHeader("foo", "bar");
|
||||
headerAccessor.setImmutable();
|
||||
|
@ -217,7 +217,7 @@ public class NativeMessageHeaderAccessorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void setImmutableIdempotent() {
|
||||
void setImmutableIdempotent() {
|
||||
NativeMessageHeaderAccessor headerAccessor = new NativeMessageHeaderAccessor();
|
||||
headerAccessor.addNativeHeader("foo", "bar");
|
||||
headerAccessor.setImmutable();
|
||||
|
|
Loading…
Reference in New Issue