Search in sources :

Example 21 with ReactiveAdapterRegistry

use of org.springframework.core.ReactiveAdapterRegistry in project spring-framework by spring-projects.

the class RequestAttributeMethodArgumentResolverTests method setup.

@BeforeEach
@SuppressWarnings("resource")
public void setup() throws Exception {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.refresh();
    ReactiveAdapterRegistry registry = ReactiveAdapterRegistry.getSharedInstance();
    this.resolver = new RequestAttributeMethodArgumentResolver(context.getBeanFactory(), registry);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ReactiveAdapterRegistry(org.springframework.core.ReactiveAdapterRegistry) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 22 with ReactiveAdapterRegistry

use of org.springframework.core.ReactiveAdapterRegistry in project spring-framework by spring-projects.

the class InitBinderBindingContextTests method createBinderTypeConversion.

@Test
public void createBinderTypeConversion() throws Exception {
    MockServerHttpRequest request = MockServerHttpRequest.get("/path?requestParam=22").build();
    MockServerWebExchange exchange = MockServerWebExchange.from(request);
    ReactiveAdapterRegistry adapterRegistry = ReactiveAdapterRegistry.getSharedInstance();
    this.argumentResolvers.add(new RequestParamMethodArgumentResolver(null, adapterRegistry, false));
    BindingContext context = createBindingContext("initBinderTypeConversion", WebDataBinder.class, int.class);
    WebDataBinder dataBinder = context.createDataBinder(exchange, null, "foo");
    assertThat(dataBinder.getDisallowedFields()).isNotNull();
    assertThat(dataBinder.getDisallowedFields()[0]).isEqualTo("requestParam-22");
}
Also used : WebDataBinder(org.springframework.web.bind.WebDataBinder) MockServerHttpRequest(org.springframework.web.testfixture.http.server.reactive.MockServerHttpRequest) ReactiveAdapterRegistry(org.springframework.core.ReactiveAdapterRegistry) MockServerWebExchange(org.springframework.web.testfixture.server.MockServerWebExchange) BindingContext(org.springframework.web.reactive.BindingContext) Test(org.junit.jupiter.api.Test)

Example 23 with ReactiveAdapterRegistry

use of org.springframework.core.ReactiveAdapterRegistry in project spring-framework by spring-projects.

the class RequestPartMethodArgumentResolverTests method setup.

@BeforeEach
void setup() {
    List<HttpMessageReader<?>> readers = ServerCodecConfigurer.create().getReaders();
    ReactiveAdapterRegistry registry = ReactiveAdapterRegistry.getSharedInstance();
    this.resolver = new RequestPartMethodArgumentResolver(readers, registry);
    List<HttpMessageWriter<?>> writers = ClientCodecConfigurer.create().getWriters();
    this.writer = new MultipartHttpMessageWriter(writers);
}
Also used : HttpMessageReader(org.springframework.http.codec.HttpMessageReader) MultipartHttpMessageWriter(org.springframework.http.codec.multipart.MultipartHttpMessageWriter) HttpMessageWriter(org.springframework.http.codec.HttpMessageWriter) ReactiveAdapterRegistry(org.springframework.core.ReactiveAdapterRegistry) MultipartHttpMessageWriter(org.springframework.http.codec.multipart.MultipartHttpMessageWriter) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 24 with ReactiveAdapterRegistry

use of org.springframework.core.ReactiveAdapterRegistry in project spring-framework by spring-projects.

the class ExpressionValueMethodArgumentResolverTests method setup.

@BeforeEach
@SuppressWarnings("resource")
public void setup() throws Exception {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.refresh();
    ReactiveAdapterRegistry adapterRegistry = ReactiveAdapterRegistry.getSharedInstance();
    this.resolver = new ExpressionValueMethodArgumentResolver(context.getBeanFactory(), adapterRegistry);
    Method method = ReflectionUtils.findMethod(getClass(), "params", (Class<?>[]) null);
    this.paramSystemProperty = new MethodParameter(method, 0);
    this.paramNotSupported = new MethodParameter(method, 1);
    this.paramAlsoNotSupported = new MethodParameter(method, 2);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ReactiveAdapterRegistry(org.springframework.core.ReactiveAdapterRegistry) Method(java.lang.reflect.Method) MethodParameter(org.springframework.core.MethodParameter) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ReactiveAdapterRegistry (org.springframework.core.ReactiveAdapterRegistry)24 BeforeEach (org.junit.jupiter.api.BeforeEach)9 Test (org.junit.jupiter.api.Test)7 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)5 BindingContext (org.springframework.web.reactive.BindingContext)5 ReactiveAdapter (org.springframework.core.ReactiveAdapter)4 ByteArrayDecoder (org.springframework.core.codec.ByteArrayDecoder)4 ByteArrayEncoder (org.springframework.core.codec.ByteArrayEncoder)4 AntPathMatcher (org.springframework.util.AntPathMatcher)4 SimpleRouteMatcher (org.springframework.util.SimpleRouteMatcher)4 Method (java.lang.reflect.Method)3 List (java.util.List)3 StringDecoder (org.springframework.core.codec.StringDecoder)3 MediaType (org.springframework.http.MediaType)3 HttpMessageWriter (org.springframework.http.codec.HttpMessageWriter)3 Nullable (org.springframework.lang.Nullable)3 Assert (org.springframework.util.Assert)3 ArrayList (java.util.ArrayList)2 Collectors (java.util.stream.Collectors)2 Publisher (org.reactivestreams.Publisher)2