Package org.springframework.amqp.rabbit.listener.adapter

Examples of org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter.onMessage()


  public void resolveConvertedPayload() throws Exception {
    MessagingMessageListenerAdapter listener = createDefaultInstance(Integer.class);

    Channel channel = mock(Channel.class);

    listener.onMessage(createTextMessage("33"), channel);
    assertDefaultListenerMethodInvocation();
  }

  @Test
  public void processAndReply() throws Exception {
View Full Code Here


    initializeFactory(customFactory);

    Method method = getListenerMethod(methodName, String.class);
    MessagingMessageListenerAdapter listener = createInstance(customFactory, method);
    Channel channel = mock(Channel.class);
    listener.onMessage(createTextMessage("test"), channel); // test is a valid value
    assertListenerMethodInvocation(sample, methodName);
  }

  @Test
  public void validatePayloadInvalid() throws Exception {
View Full Code Here

    Method method = getListenerMethod("validatePayload", String.class);
    MessagingMessageListenerAdapter listener = createInstance(customFactory, method);
    Channel channel = mock(Channel.class);

    thrown.expect(ListenerExecutionFailedException.class);
    listener.onMessage(createTextMessage("invalid value"), channel); // test is an invalid value

  }

  // failure scenario
View Full Code Here

    Channel channel = mock(Channel.class);

    thrown.expect(ListenerExecutionFailedException.class);
    thrown.expectCause(Matchers.isA(MessageConversionException.class));
    thrown.expectMessage(getDefaultListenerMethod(Integer.class).toGenericString()); // ref to method
    listener.onMessage(createTextMessage("test"), channel); // test is not a valid integer
  }

  @Test
  public void invalidMessagePayloadType() throws Exception {
    MessagingMessageListenerAdapter listener = createDefaultInstance(Message.class);
View Full Code Here

    MessagingMessageListenerAdapter listener = createDefaultInstance(Message.class);
    Channel channel = mock(Channel.class);

    thrown.expect(ListenerExecutionFailedException.class);
    thrown.expectCause(Matchers.isA(MethodArgumentTypeMismatchException.class));
    listener.onMessage(createTextMessage("test"), channel)// Message<String> as Message<Integer>
  }

  private MessagingMessageListenerAdapter createInstance(
      DefaultMessageHandlerMethodFactory factory, Method method, MessageListenerContainer container) {
    MethodRabbitListenerEndpoint endpoint = new MethodRabbitListenerEndpoint();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.