use of org.springframework.util.AntPathMatcher in project spring-framework by spring-projects.
the class MethodMessageHandlerTests method handleException.
@Test
@SuppressWarnings("unchecked")
public void handleException() {
TestMethodMessageHandler handler = initMethodMessageHandler(TestController.class);
Message<?> message = new GenericMessage<>("body", Collections.singletonMap(DestinationPatternsMessageCondition.LOOKUP_DESTINATION_HEADER, new SimpleRouteMatcher(new AntPathMatcher()).parseRoute("/handleMessageWithError")));
handler.handleMessage(message).block(Duration.ofSeconds(5));
StepVerifier.create((Publisher<Object>) handler.getLastReturnValue()).expectNext("handleIllegalStateException,ex=rejected").verifyComplete();
}
use of org.springframework.util.AntPathMatcher in project spring-framework by spring-projects.
the class RSocketMessageHandlerTests method getRSocketStrategiesReflectsCurrentState.
@Test
public void getRSocketStrategiesReflectsCurrentState() {
RSocketMessageHandler handler = new RSocketMessageHandler();
// 1. Set properties
handler.setDecoders(Collections.singletonList(new ByteArrayDecoder()));
handler.setEncoders(Collections.singletonList(new ByteArrayEncoder()));
handler.setRouteMatcher(new SimpleRouteMatcher(new AntPathMatcher()));
handler.setMetadataExtractor(new DefaultMetadataExtractor());
handler.setReactiveAdapterRegistry(new ReactiveAdapterRegistry());
RSocketStrategies strategies = handler.getRSocketStrategies();
assertThat(strategies.encoders()).isEqualTo(handler.getEncoders());
assertThat(strategies.decoders()).isEqualTo(handler.getDecoders());
assertThat(strategies.routeMatcher()).isSameAs(handler.getRouteMatcher());
assertThat(strategies.metadataExtractor()).isSameAs(handler.getMetadataExtractor());
assertThat(strategies.reactiveAdapterRegistry()).isSameAs(handler.getReactiveAdapterRegistry());
// 2. Set properties again
handler.setDecoders(Collections.singletonList(StringDecoder.allMimeTypes()));
handler.setEncoders(Collections.singletonList(CharSequenceEncoder.allMimeTypes()));
handler.setRouteMatcher(new SimpleRouteMatcher(new AntPathMatcher()));
handler.setMetadataExtractor(new DefaultMetadataExtractor());
handler.setReactiveAdapterRegistry(new ReactiveAdapterRegistry());
handler.afterPropertiesSet();
strategies = handler.getRSocketStrategies();
assertThat(strategies.encoders()).isEqualTo(handler.getEncoders());
assertThat(strategies.decoders()).isEqualTo(handler.getDecoders());
assertThat(strategies.routeMatcher()).isSameAs(handler.getRouteMatcher());
assertThat(strategies.metadataExtractor()).isSameAs(handler.getMetadataExtractor());
assertThat(strategies.reactiveAdapterRegistry()).isSameAs(handler.getReactiveAdapterRegistry());
}
use of org.springframework.util.AntPathMatcher in project spring-framework by spring-projects.
the class RSocketMessageHandlerTests method getRSocketStrategies.
@Test
public void getRSocketStrategies() {
RSocketMessageHandler handler = new RSocketMessageHandler();
handler.setDecoders(Collections.singletonList(new ByteArrayDecoder()));
handler.setEncoders(Collections.singletonList(new ByteArrayEncoder()));
handler.setRouteMatcher(new SimpleRouteMatcher(new AntPathMatcher()));
handler.setMetadataExtractor(new DefaultMetadataExtractor());
handler.setReactiveAdapterRegistry(new ReactiveAdapterRegistry());
RSocketStrategies strategies = handler.getRSocketStrategies();
assertThat(strategies).isNotNull();
assertThat(strategies.encoders()).isEqualTo(handler.getEncoders());
assertThat(strategies.decoders()).isEqualTo(handler.getDecoders());
assertThat(strategies.routeMatcher()).isSameAs(handler.getRouteMatcher());
assertThat(strategies.metadataExtractor()).isSameAs(handler.getMetadataExtractor());
assertThat(strategies.reactiveAdapterRegistry()).isSameAs(handler.getReactiveAdapterRegistry());
}
use of org.springframework.util.AntPathMatcher in project xm-ms-entity by xm-online.
the class PathMatcherUnitTest method testMatcher.
@Test
public void testMatcher() {
AntPathMatcher matcher = new AntPathMatcher();
String url = "/config/tenants/XM/entity/specs/xmentityspecs.yml";
String pattern = "/config/tenants/{tenantName}/entity/specs/xmentityspecs.yml";
assertTrue(matcher.match(pattern, url));
assertEquals("XM", matcher.extractUriTemplateVariables(pattern, url).get("tenantName"));
}
use of org.springframework.util.AntPathMatcher in project libresonic by Libresonic.
the class ControllerUtils method extractMatched.
public static String extractMatched(final HttpServletRequest request) {
String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
String bestMatchPattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
AntPathMatcher apm = new AntPathMatcher();
return apm.extractPathWithinPattern(bestMatchPattern, path);
}
Aggregations