use of org.springframework.util.AntPathMatcher in project spring-framework by spring-projects.
the class DestinationPatternsMessageConditionTests method prependSlashWithCustomPathSeparator.
@Test
public void prependSlashWithCustomPathSeparator() {
DestinationPatternsMessageCondition c = new DestinationPatternsMessageCondition(new String[] { "foo" }, new AntPathMatcher("."));
assertThat(c.getPatterns().iterator().next()).as("Pre-pending should be disabled when not using '/' as path separator").isEqualTo("foo");
}
use of org.springframework.util.AntPathMatcher in project spring-framework by spring-projects.
the class MessageMappingMessageHandlerTests method message.
private Message<?> message(String destination, String... content) {
Flux<DataBuffer> payload = Flux.fromIterable(Arrays.asList(content)).map(this::toDataBuffer);
MessageHeaderAccessor headers = new MessageHeaderAccessor();
headers.setLeaveMutable(true);
headers.setHeader(DestinationPatternsMessageCondition.LOOKUP_DESTINATION_HEADER, new SimpleRouteMatcher(new AntPathMatcher()).parseRoute(destination));
return MessageBuilder.createMessage(payload, headers.getMessageHeaders());
}
use of org.springframework.util.AntPathMatcher in project spring-framework by spring-projects.
the class MessageMappingMessageHandlerTests method unhandledExceptionShouldFlowThrough.
@Test
public void unhandledExceptionShouldFlowThrough() {
GenericMessage<?> message = new GenericMessage<>(new Object(), Collections.singletonMap(DestinationPatternsMessageCondition.LOOKUP_DESTINATION_HEADER, new SimpleRouteMatcher(new AntPathMatcher()).parseRoute("string")));
StepVerifier.create(initMesssageHandler().handleMessage(message)).expectErrorSatisfies(ex -> assertThat(ex.getMessage().startsWith("Could not resolve method parameter at index 0")).as("Actual: " + ex.getMessage()).isTrue()).verify(Duration.ofSeconds(5));
}
use of org.springframework.util.AntPathMatcher in project spring-framework by spring-projects.
the class MethodMessageHandlerTests method bestMatch.
@Test
@SuppressWarnings("unchecked")
public void bestMatch() throws NoSuchMethodException {
TestMethodMessageHandler handler = new TestMethodMessageHandler();
TestController controller = new TestController();
handler.registerHandlerMethod(controller, TestController.class.getMethod("handleMessageMatch1"), "/bestmatch/{foo}/path");
handler.registerHandlerMethod(controller, TestController.class.getMethod("handleMessageMatch2"), "/bestmatch/*/*");
handler.afterPropertiesSet();
Message<?> message = new GenericMessage<>("body", Collections.singletonMap(DestinationPatternsMessageCondition.LOOKUP_DESTINATION_HEADER, new SimpleRouteMatcher(new AntPathMatcher()).parseRoute("/bestmatch/bar/path")));
handler.handleMessage(message).block(Duration.ofSeconds(5));
StepVerifier.create((Publisher<Object>) handler.getLastReturnValue()).expectNext("handleMessageMatch1").verifyComplete();
}
use of org.springframework.util.AntPathMatcher in project spring-framework by spring-projects.
the class MethodMessageHandlerTests method argumentResolution.
@Test
@SuppressWarnings("unchecked")
public void argumentResolution() {
ArgumentResolverConfigurer configurer = new ArgumentResolverConfigurer();
configurer.addCustomResolver(new StubArgumentResolver(String.class, "foo"));
TestMethodMessageHandler handler = initMethodMessageHandler(theHandler -> theHandler.setArgumentResolverConfigurer(configurer), TestController.class);
Message<?> message = new GenericMessage<>("body", Collections.singletonMap(DestinationPatternsMessageCondition.LOOKUP_DESTINATION_HEADER, new SimpleRouteMatcher(new AntPathMatcher()).parseRoute("/handleMessageWithArgument")));
handler.handleMessage(message).block(Duration.ofSeconds(5));
StepVerifier.create((Publisher<Object>) handler.getLastReturnValue()).expectNext("handleMessageWithArgument,payload=foo").verifyComplete();
}
Aggregations