use of org.springframework.web.util.pattern.PathPatternParser in project spring-framework by spring-projects.
the class RequestMappingInfoTests method mutate.
@Test
void mutate() {
RequestMappingInfo.BuilderConfiguration options = new RequestMappingInfo.BuilderConfiguration();
options.setPatternParser(new PathPatternParser());
RequestMappingInfo info1 = RequestMappingInfo.paths("/foo").methods(GET).headers("h1=hv1").params("q1=qv1").consumes("application/json").produces("application/json").mappingName("testMapping").options(options).build();
RequestMappingInfo info2 = info1.mutate().produces("application/hal+json").build();
assertThat(info2.getName()).isEqualTo(info1.getName());
assertThat(info2.getPatternsCondition()).isNull();
assertThat(info2.getPathPatternsCondition()).isEqualTo(info1.getPathPatternsCondition());
assertThat(info2.getHeadersCondition()).isEqualTo(info1.getHeadersCondition());
assertThat(info2.getParamsCondition()).isEqualTo(info1.getParamsCondition());
assertThat(info2.getConsumesCondition()).isEqualTo(info1.getConsumesCondition());
assertThat(info2.getProducesCondition().getProducibleMediaTypes()).containsOnly(MediaType.parseMediaType("application/hal+json"));
}
use of org.springframework.web.util.pattern.PathPatternParser in project spring-framework by spring-projects.
the class RequestMappingInfoHandlerMappingTests method pathPatternsArguments.
@SuppressWarnings("unused")
static Stream<?> pathPatternsArguments() {
TestController controller = new TestController();
TestRequestMappingInfoHandlerMapping mapping1 = new TestRequestMappingInfoHandlerMapping();
mapping1.setPatternParser(new PathPatternParser());
TestRequestMappingInfoHandlerMapping mapping2 = new TestRequestMappingInfoHandlerMapping();
mapping2.setRemoveSemicolonContent(false);
return Stream.of(mapping1, mapping2).peek(mapping -> {
mapping.setApplicationContext(new StaticWebApplicationContext());
mapping.registerHandler(controller);
mapping.afterPropertiesSet();
});
}
use of org.springframework.web.util.pattern.PathPatternParser in project spring-framework by spring-projects.
the class RequestMappingInfoTests method mutate.
@Test
void mutate() {
RequestMappingInfo.BuilderConfiguration options = new RequestMappingInfo.BuilderConfiguration();
options.setPatternParser(new PathPatternParser());
RequestMappingInfo info1 = RequestMappingInfo.paths("/foo").methods(GET).headers("h1=hv1").params("q1=qv1").consumes("application/json").produces("application/json").mappingName("testMapping").options(options).build();
RequestMappingInfo info2 = info1.mutate().produces("application/hal+json").build();
assertThat(info2.getName()).isEqualTo(info1.getName());
assertThat(info2.getPatternsCondition()).isEqualTo(info1.getPatternsCondition());
assertThat(info2.getHeadersCondition()).isEqualTo(info1.getHeadersCondition());
assertThat(info2.getParamsCondition()).isEqualTo(info1.getParamsCondition());
assertThat(info2.getConsumesCondition()).isEqualTo(info1.getConsumesCondition());
assertThat(info2.getProducesCondition().getProducibleMediaTypes()).containsOnly(MediaType.parseMediaType("application/hal+json"));
}
use of org.springframework.web.util.pattern.PathPatternParser in project spring-framework by spring-projects.
the class RouterFunctionMapping method afterPropertiesSet.
@Override
public void afterPropertiesSet() throws Exception {
if (this.routerFunction == null) {
initRouterFunction();
}
if (CollectionUtils.isEmpty(this.messageConverters)) {
initMessageConverters();
}
if (this.routerFunction != null) {
PathPatternParser patternParser = getPatternParser();
if (patternParser == null) {
patternParser = new PathPatternParser();
setPatternParser(patternParser);
}
RouterFunctions.changeParser(this.routerFunction, patternParser);
}
}
use of org.springframework.web.util.pattern.PathPatternParser in project spring-framework by spring-projects.
the class CrossOriginTests method pathPatternsArguments.
@SuppressWarnings("unused")
static Stream<TestRequestMappingInfoHandlerMapping> pathPatternsArguments() {
StaticWebApplicationContext wac = new StaticWebApplicationContext();
Properties props = new Properties();
props.setProperty("myOrigin", "https://example.com");
props.setProperty("myDomainPattern", "http://*.example.com");
wac.getEnvironment().getPropertySources().addFirst(new PropertiesPropertySource("ps", props));
wac.registerSingleton("ppc", PropertySourcesPlaceholderConfigurer.class);
wac.refresh();
TestRequestMappingInfoHandlerMapping mapping1 = new TestRequestMappingInfoHandlerMapping();
mapping1.setPatternParser(new PathPatternParser());
wac.getAutowireCapableBeanFactory().initializeBean(mapping1, "mapping1");
TestRequestMappingInfoHandlerMapping mapping2 = new TestRequestMappingInfoHandlerMapping();
wac.getAutowireCapableBeanFactory().initializeBean(mapping2, "mapping2");
wac.close();
return Stream.of(mapping1, mapping2);
}
Aggregations