Search in sources :

Example 21 with SynthesizingMethodParameter

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

the class HeaderMethodArgumentResolverTests method setup.

@Before
public void setup() throws Exception {
    @SuppressWarnings("resource") GenericApplicationContext cxt = new GenericApplicationContext();
    cxt.refresh();
    this.resolver = new HeaderMethodArgumentResolver(new DefaultConversionService(), cxt.getBeanFactory());
    Method method = ReflectionUtils.findMethod(getClass(), "handleMessage", (Class<?>[]) null);
    this.paramRequired = new SynthesizingMethodParameter(method, 0);
    this.paramNamedDefaultValueStringHeader = new SynthesizingMethodParameter(method, 1);
    this.paramSystemPropertyDefaultValue = new SynthesizingMethodParameter(method, 2);
    this.paramSystemPropertyName = new SynthesizingMethodParameter(method, 3);
    this.paramNotAnnotated = new SynthesizingMethodParameter(method, 4);
    this.paramOptional = new SynthesizingMethodParameter(method, 5);
    this.paramNativeHeader = new SynthesizingMethodParameter(method, 6);
    this.paramRequired.initParameterNameDiscovery(new DefaultParameterNameDiscoverer());
    GenericTypeResolver.resolveParameterType(this.paramRequired, HeaderMethodArgumentResolver.class);
}
Also used : SynthesizingMethodParameter(org.springframework.core.annotation.SynthesizingMethodParameter) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) DefaultParameterNameDiscoverer(org.springframework.core.DefaultParameterNameDiscoverer) DefaultConversionService(org.springframework.core.convert.support.DefaultConversionService) Method(java.lang.reflect.Method) Before(org.junit.Before)

Example 22 with SynthesizingMethodParameter

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

the class PayloadArgumentResolverTests method setup.

@Before
public void setup() throws Exception {
    this.resolver = new PayloadArgumentResolver(new StringMessageConverter(), testValidator());
    Method payloadMethod = PayloadArgumentResolverTests.class.getDeclaredMethod("handleMessage", String.class, String.class, Locale.class, String.class, String.class, String.class, String.class);
    this.paramAnnotated = new SynthesizingMethodParameter(payloadMethod, 0);
    this.paramAnnotatedNotRequired = new SynthesizingMethodParameter(payloadMethod, 1);
    this.paramAnnotatedRequired = new SynthesizingMethodParameter(payloadMethod, 2);
    this.paramWithSpelExpression = new SynthesizingMethodParameter(payloadMethod, 3);
    this.paramValidated = new SynthesizingMethodParameter(payloadMethod, 4);
    this.paramValidated.initParameterNameDiscovery(new LocalVariableTableParameterNameDiscoverer());
    this.paramValidatedNotAnnotated = new SynthesizingMethodParameter(payloadMethod, 5);
    this.paramNotAnnotated = new SynthesizingMethodParameter(payloadMethod, 6);
}
Also used : StringMessageConverter(org.springframework.messaging.converter.StringMessageConverter) LocalVariableTableParameterNameDiscoverer(org.springframework.core.LocalVariableTableParameterNameDiscoverer) SynthesizingMethodParameter(org.springframework.core.annotation.SynthesizingMethodParameter) Method(java.lang.reflect.Method) 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