title: How to mock a bean with Service Activator?
body: <p>I am trying to create a test for this bean that I have found. </p>
  
  <pre><code>public class MyClass() {
  @Bean
  @ServiceActivator(inputChannel = "sftpChannel")
  public MessageHandler handler() {
      logger.info("I am here");
      return new MessageHandler() {
  
          @Override
          public void handleMessage(Message&lt;?&gt; message) throws MessagingException {
              System.out.println(message.getPayload());
          }
  
      };
  }
  }
  </code></pre>
  
  <p>Here is the test class as I have it,</p>
  
  <pre><code>@InjectMocks
  private MyClass myClass;
  
  @Test
  public void testExample() {
     myClass.handler();
  }
  </code></pre>
  
  <p>My problem is that when I call it in the test, it prints the "I am Here" but not the payload, as it seems it does not reach in this point. Any suggestions please? Or any other proper ways of testing it?</p>