use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class MessageMethodArgumentResolverTests method resolveWithConversionEmptyPayloadButNoConverter.
@Test
public void resolveWithConversionEmptyPayloadButNoConverter() throws Exception {
this.resolver = new MessageMethodArgumentResolver();
Message<String> message = MessageBuilder.withPayload("").build();
MethodParameter parameter = new MethodParameter(this.method, 1);
assertTrue(this.resolver.supportsParameter(parameter));
thrown.expect(MessageConversionException.class);
thrown.expectMessage("payload is empty");
thrown.expectMessage(Integer.class.getName());
thrown.expectMessage(String.class.getName());
this.resolver.resolveArgument(parameter, message);
}
use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class MessageMethodArgumentResolverTests method resolveWithMessageSubclassAndPayloadWildcard.
@Test
public void resolveWithMessageSubclassAndPayloadWildcard() throws Exception {
ErrorMessage message = new ErrorMessage(new UnsupportedOperationException());
MethodParameter parameter = new MethodParameter(this.method, 0);
assertTrue(this.resolver.supportsParameter(parameter));
assertSame(message, this.resolver.resolveArgument(parameter, message));
}
use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class MessageMethodArgumentResolverTests method resolveWithPayloadTypeAsWildcardAndNoConverter.
@Test
public void resolveWithPayloadTypeAsWildcardAndNoConverter() throws Exception {
this.resolver = new MessageMethodArgumentResolver();
Message<String> message = MessageBuilder.withPayload("test").build();
MethodParameter parameter = new MethodParameter(this.method, 0);
assertTrue(this.resolver.supportsParameter(parameter));
assertSame(message, this.resolver.resolveArgument(parameter, message));
}
use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class MessageMethodArgumentResolverTests method resolveWithPayloadTypeUpperBound.
@Test
public void resolveWithPayloadTypeUpperBound() throws Exception {
Message<Integer> message = MessageBuilder.withPayload(123).build();
MethodParameter parameter = new MethodParameter(this.method, 3);
assertTrue(this.resolver.supportsParameter(parameter));
assertSame(message, this.resolver.resolveArgument(parameter, message));
}
use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class SendToMethodReturnValueHandlerTests method sendToUserWithSendToDefaultOverride.
// SPR-14238
@Test
public void sendToUserWithSendToDefaultOverride() throws Exception {
given(this.messageChannel.send(any(Message.class))).willReturn(true);
Class<?> clazz = SendToUserWithSendToOverrideTestBean.class;
Method method = clazz.getDeclaredMethod("handleAndSendToDefaultDestination");
MethodParameter parameter = new SynthesizingMethodParameter(method, -1);
String sessionId = "sess1";
Message<?> inputMessage = createMessage(sessionId, "sub1", null, null, null);
this.handler.handleReturnValue(PAYLOAD, parameter, inputMessage);
verify(this.messageChannel, times(1)).send(this.messageCaptor.capture());
assertResponse(parameter, sessionId, 0, "/user/sess1/dest-default");
}
Aggregations