Search in sources :

Example 11 with SynthesizingMethodParameter

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

the class PathVariableMethodArgumentResolverTests method setup.

@Before
public void setup() throws Exception {
    this.resolver = new PathVariableMethodArgumentResolver(null, new ReactiveAdapterRegistry());
    Method method = ReflectionUtils.findMethod(getClass(), "handle", (Class<?>[]) null);
    paramNamedString = new SynthesizingMethodParameter(method, 0);
    paramString = new SynthesizingMethodParameter(method, 1);
    paramNotRequired = new SynthesizingMethodParameter(method, 2);
    paramOptional = new SynthesizingMethodParameter(method, 3);
    paramMono = 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 12 with SynthesizingMethodParameter

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

the class PathVariableMethodArgumentResolverTests method setup.

@Before
public void setup() throws Exception {
    resolver = new PathVariableMethodArgumentResolver();
    mavContainer = new ModelAndViewContainer();
    request = new MockHttpServletRequest();
    webRequest = new ServletWebRequest(request, new MockHttpServletResponse());
    Method method = ReflectionUtils.findMethod(getClass(), "handle", (Class<?>[]) null);
    paramNamedString = new SynthesizingMethodParameter(method, 0);
    paramString = new SynthesizingMethodParameter(method, 1);
    paramNotRequired = new SynthesizingMethodParameter(method, 2);
    paramOptional = new SynthesizingMethodParameter(method, 3);
}
Also used : SynthesizingMethodParameter(org.springframework.core.annotation.SynthesizingMethodParameter) ModelAndViewContainer(org.springframework.web.method.support.ModelAndViewContainer) MockHttpServletRequest(org.springframework.mock.web.test.MockHttpServletRequest) Method(java.lang.reflect.Method) ServletWebRequest(org.springframework.web.context.request.ServletWebRequest) MockHttpServletResponse(org.springframework.mock.web.test.MockHttpServletResponse) Before(org.junit.Before)

Example 13 with SynthesizingMethodParameter

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

the class MatrixVariablesMapMethodArgumentResolverTests method setup.

@Before
public void setup() throws Exception {
    this.resolver = new MatrixVariableMapMethodArgumentResolver();
    this.mavContainer = new ModelAndViewContainer();
    this.request = new MockHttpServletRequest();
    this.webRequest = new ServletWebRequest(request, new MockHttpServletResponse());
    Map<String, MultiValueMap<String, String>> params = new LinkedHashMap<>();
    this.request.setAttribute(HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE, params);
    Method method = getClass().getMethod("handle", String.class, Map.class, MultiValueMap.class, MultiValueMap.class, Map.class);
    this.paramString = new SynthesizingMethodParameter(method, 0);
    this.paramMap = new SynthesizingMethodParameter(method, 1);
    this.paramMultivalueMap = new SynthesizingMethodParameter(method, 2);
    this.paramMapForPathVar = new SynthesizingMethodParameter(method, 3);
    this.paramMapWithName = new SynthesizingMethodParameter(method, 4);
}
Also used : SynthesizingMethodParameter(org.springframework.core.annotation.SynthesizingMethodParameter) ModelAndViewContainer(org.springframework.web.method.support.ModelAndViewContainer) MockHttpServletRequest(org.springframework.mock.web.test.MockHttpServletRequest) Method(java.lang.reflect.Method) ServletWebRequest(org.springframework.web.context.request.ServletWebRequest) MockHttpServletResponse(org.springframework.mock.web.test.MockHttpServletResponse) MultiValueMap(org.springframework.util.MultiValueMap) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) LinkedHashMap(java.util.LinkedHashMap) Before(org.junit.Before)

Example 14 with SynthesizingMethodParameter

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

the class AbstractRequestAttributesArgumentResolverTests method initMethodParameter.

private MethodParameter initMethodParameter(int parameterIndex) {
    MethodParameter param = new SynthesizingMethodParameter(this.handleMethod, parameterIndex);
    param.initParameterNameDiscovery(new DefaultParameterNameDiscoverer());
    GenericTypeResolver.resolveParameterType(param, this.resolver.getClass());
    return param;
}
Also used : SynthesizingMethodParameter(org.springframework.core.annotation.SynthesizingMethodParameter) DefaultParameterNameDiscoverer(org.springframework.core.DefaultParameterNameDiscoverer) MethodParameter(org.springframework.core.MethodParameter) SynthesizingMethodParameter(org.springframework.core.annotation.SynthesizingMethodParameter)

Example 15 with SynthesizingMethodParameter

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

the class RequestHeaderMethodArgumentResolverTests method setUp.

@Before
@SuppressWarnings("resource")
public void setUp() throws Exception {
    GenericWebApplicationContext context = new GenericWebApplicationContext();
    context.refresh();
    resolver = new RequestHeaderMethodArgumentResolver(context.getBeanFactory());
    Method method = ReflectionUtils.findMethod(getClass(), "params", (Class<?>[]) null);
    paramNamedDefaultValueStringHeader = new SynthesizingMethodParameter(method, 0);
    paramNamedValueStringArray = new SynthesizingMethodParameter(method, 1);
    paramSystemProperty = new SynthesizingMethodParameter(method, 2);
    paramContextPath = new SynthesizingMethodParameter(method, 3);
    paramResolvedNameWithExpression = new SynthesizingMethodParameter(method, 4);
    paramResolvedNameWithPlaceholder = new SynthesizingMethodParameter(method, 5);
    paramNamedValueMap = new SynthesizingMethodParameter(method, 6);
    paramDate = new SynthesizingMethodParameter(method, 7);
    paramInstant = new SynthesizingMethodParameter(method, 8);
    servletRequest = new MockHttpServletRequest();
    webRequest = new ServletWebRequest(servletRequest, new MockHttpServletResponse());
    // Expose request to the current thread (for SpEL expressions)
    RequestContextHolder.setRequestAttributes(webRequest);
}
Also used : SynthesizingMethodParameter(org.springframework.core.annotation.SynthesizingMethodParameter) MockHttpServletRequest(org.springframework.mock.web.test.MockHttpServletRequest) Method(java.lang.reflect.Method) GenericWebApplicationContext(org.springframework.web.context.support.GenericWebApplicationContext) ServletWebRequest(org.springframework.web.context.request.ServletWebRequest) MockHttpServletResponse(org.springframework.mock.web.test.MockHttpServletResponse) Before(org.junit.Before)

Aggregations

SynthesizingMethodParameter (org.springframework.core.annotation.SynthesizingMethodParameter)22 Method (java.lang.reflect.Method)17 Before (org.junit.Before)15 MethodParameter (org.springframework.core.MethodParameter)8 ServletWebRequest (org.springframework.web.context.request.ServletWebRequest)8 MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)7 MockHttpServletResponse (org.springframework.mock.web.test.MockHttpServletResponse)7 DefaultParameterNameDiscoverer (org.springframework.core.DefaultParameterNameDiscoverer)4 ReactiveAdapterRegistry (org.springframework.core.ReactiveAdapterRegistry)4 ModelAndViewContainer (org.springframework.web.method.support.ModelAndViewContainer)3 Test (org.junit.Test)2 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)2 LocalVariableTableParameterNameDiscoverer (org.springframework.core.LocalVariableTableParameterNameDiscoverer)2 Message (org.springframework.messaging.Message)2 StringMessageConverter (org.springframework.messaging.converter.StringMessageConverter)2 BindingContext (org.springframework.web.reactive.BindingContext)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 DependencyDescriptor (org.springframework.beans.factory.config.DependencyDescriptor)1 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)1