Search in sources :

Example 6 with ReactiveAdapterRegistry

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

the class RequestHeaderMapMethodArgumentResolverTests method setup.

@Before
public void setup() throws Exception {
    resolver = new RequestHeaderMapMethodArgumentResolver(new ReactiveAdapterRegistry());
    Method method = ReflectionUtils.findMethod(getClass(), "params", (Class<?>[]) null);
    paramMap = new SynthesizingMethodParameter(method, 0);
    paramMultiValueMap = new SynthesizingMethodParameter(method, 1);
    paramHttpHeaders = new SynthesizingMethodParameter(method, 2);
    paramUnsupported = new SynthesizingMethodParameter(method, 3);
    paramUnsupported = new SynthesizingMethodParameter(method, 3);
    paramAlsoUnsupported = new SynthesizingMethodParameter(method, 4);
}
Also used : SynthesizingMethodParameter(org.springframework.core.annotation.SynthesizingMethodParameter) ReactiveAdapterRegistry(org.springframework.core.ReactiveAdapterRegistry) Method(java.lang.reflect.Method) Before(org.junit.Before)

Example 7 with ReactiveAdapterRegistry

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

the class RequestHeaderMethodArgumentResolverTests method setup.

@Before
public void setup() throws Exception {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.refresh();
    ReactiveAdapterRegistry adapterRegistry = new ReactiveAdapterRegistry();
    this.resolver = new RequestHeaderMethodArgumentResolver(context.getBeanFactory(), adapterRegistry);
    ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer();
    initializer.setConversionService(new DefaultFormattingConversionService());
    this.bindingContext = new BindingContext(initializer);
    Method method = ReflectionUtils.findMethod(getClass(), "params", (Class<?>[]) null);
    this.paramNamedDefaultValueStringHeader = new SynthesizingMethodParameter(method, 0);
    this.paramNamedValueStringArray = new SynthesizingMethodParameter(method, 1);
    this.paramSystemProperty = new SynthesizingMethodParameter(method, 2);
    this.paramResolvedNameWithExpression = new SynthesizingMethodParameter(method, 3);
    this.paramResolvedNameWithPlaceholder = new SynthesizingMethodParameter(method, 4);
    this.paramNamedValueMap = new SynthesizingMethodParameter(method, 5);
    this.paramDate = new SynthesizingMethodParameter(method, 6);
    this.paramInstant = new SynthesizingMethodParameter(method, 7);
    this.paramMono = new SynthesizingMethodParameter(method, 8);
}
Also used : SynthesizingMethodParameter(org.springframework.core.annotation.SynthesizingMethodParameter) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ConfigurableWebBindingInitializer(org.springframework.web.bind.support.ConfigurableWebBindingInitializer) ReactiveAdapterRegistry(org.springframework.core.ReactiveAdapterRegistry) Method(java.lang.reflect.Method) BindingContext(org.springframework.web.reactive.BindingContext) DefaultFormattingConversionService(org.springframework.format.support.DefaultFormattingConversionService) Before(org.junit.Before)

Example 8 with ReactiveAdapterRegistry

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

the class SessionAttributeMethodArgumentResolverTests method setup.

@Before
public void setup() throws Exception {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.refresh();
    ReactiveAdapterRegistry adapterRegistry = new ReactiveAdapterRegistry();
    this.resolver = new SessionAttributeMethodArgumentResolver(context.getBeanFactory(), adapterRegistry);
    this.session = mock(WebSession.class);
    WebSessionManager sessionManager = new MockWebSessionManager(this.session);
    ServerHttpRequest request = MockServerHttpRequest.get("/").build();
    this.exchange = new DefaultServerWebExchange(request, new MockServerHttpResponse(), sessionManager);
    this.handleMethod = ReflectionUtils.findMethod(getClass(), "handleWithSessionAttribute", (Class<?>[]) null);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) DefaultServerWebExchange(org.springframework.web.server.adapter.DefaultServerWebExchange) WebSession(org.springframework.web.server.WebSession) MockWebSessionManager(org.springframework.web.server.session.MockWebSessionManager) ReactiveAdapterRegistry(org.springframework.core.ReactiveAdapterRegistry) ServerHttpRequest(org.springframework.http.server.reactive.ServerHttpRequest) MockServerHttpRequest(org.springframework.mock.http.server.reactive.test.MockServerHttpRequest) MockWebSessionManager(org.springframework.web.server.session.MockWebSessionManager) WebSessionManager(org.springframework.web.server.session.WebSessionManager) MockServerHttpResponse(org.springframework.mock.http.server.reactive.test.MockServerHttpResponse) Before(org.junit.Before)

Example 9 with ReactiveAdapterRegistry

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

the class RequestParamMethodArgumentResolverTests method doesNotSupportParameterWithDefaultResolutionTurnedOff.

@Test
public void doesNotSupportParameterWithDefaultResolutionTurnedOff() {
    ReactiveAdapterRegistry adapterRegistry = new ReactiveAdapterRegistry();
    this.resolver = new RequestParamMethodArgumentResolver(null, adapterRegistry, false);
    MethodParameter param = this.testMethod.annotNotPresent(RequestParam.class).arg(String.class);
    assertFalse(this.resolver.supportsParameter(param));
}
Also used : RequestParam(org.springframework.web.bind.annotation.RequestParam) ReactiveAdapterRegistry(org.springframework.core.ReactiveAdapterRegistry) MethodParameter(org.springframework.core.MethodParameter) Test(org.junit.Test)

Example 10 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 {
    ServerWebExchange exchange = MockServerHttpRequest.get("/path?requestParam=22").toExchange();
    ReactiveAdapterRegistry adapterRegistry = new ReactiveAdapterRegistry();
    this.argumentResolvers.add(new RequestParamMethodArgumentResolver(null, adapterRegistry, false));
    BindingContext context = createBindingContext("initBinderTypeConversion", WebDataBinder.class, int.class);
    WebDataBinder dataBinder = context.createDataBinder(exchange, null, "foo");
    assertNotNull(dataBinder.getDisallowedFields());
    assertEquals("requestParam-22", dataBinder.getDisallowedFields()[0]);
}
Also used : ServerWebExchange(org.springframework.web.server.ServerWebExchange) WebDataBinder(org.springframework.web.bind.WebDataBinder) ReactiveAdapterRegistry(org.springframework.core.ReactiveAdapterRegistry) BindingContext(org.springframework.web.reactive.BindingContext) Test(org.junit.Test)

Aggregations

ReactiveAdapterRegistry (org.springframework.core.ReactiveAdapterRegistry)16 Before (org.junit.Before)10 Method (java.lang.reflect.Method)6 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)5 MethodParameter (org.springframework.core.MethodParameter)5 Test (org.junit.Test)4 SynthesizingMethodParameter (org.springframework.core.annotation.SynthesizingMethodParameter)4 BindingContext (org.springframework.web.reactive.BindingContext)4 DefaultFormattingConversionService (org.springframework.format.support.DefaultFormattingConversionService)2 ModelAttribute (org.springframework.web.bind.annotation.ModelAttribute)2 ConfigurableWebBindingInitializer (org.springframework.web.bind.support.ConfigurableWebBindingInitializer)2 Mono (reactor.core.publisher.Mono)2 ArrayList (java.util.ArrayList)1 StringDecoder (org.springframework.core.codec.StringDecoder)1 DecoderHttpMessageReader (org.springframework.http.codec.DecoderHttpMessageReader)1 HttpMessageReader (org.springframework.http.codec.HttpMessageReader)1 ServerHttpRequest (org.springframework.http.server.reactive.ServerHttpRequest)1 MockServerHttpRequest (org.springframework.mock.http.server.reactive.test.MockServerHttpRequest)1 MockServerHttpResponse (org.springframework.mock.http.server.reactive.test.MockServerHttpResponse)1 WebDataBinder (org.springframework.web.bind.WebDataBinder)1