title: Mock JMS MessageSource
body: <p>I have a set of <code>MessageSource</code>s (in fact <code>JmsDestinationPollingSource</code>s) which are polled regularly. Under the hood this is an Oracle AQ database that persists queue items.</p>
  
  <pre><code>@Bean
  @InboundChannelAdapter(value = "queueSourceChannel", poller = @Poller(fixedDelay = "1000"))
  public MessageSource queueSource() {
      return Jms
              .inboundAdapter(connectionFactory)
              .configureJmsTemplate(t -&gt; t.deliveryPersistent(true)
                              .jmsMessageConverter(jacksonJmsMessageConverter)
              ).destination(queueName).get();
  }
  </code></pre>
  
  <p>However, now, I would like to make a <code>@SpringBootTest</code> without the Oracle persistence of course.</p>
  
  <p>The way I did this now, was by mocking (Mockito) the above Bean:</p>
  
  <pre><code>@MockBean(name = "queueSource")
  private MessageSource queueSource;
  </code></pre>
  
  <p>This way, the test class can be run, without having to worry that the MessageSource is polled.</p>
  
  <p>However, as I mentioned, I have multiple MessageSource's and I'd like to disable this polling another way.</p>
  
  <p>The way I'm doing this now is stupid:</p>
  
  <pre><code>@MockBean(name = "queueSource")
  private MessageSource queueSource;
  
  @MockBean(name = "queueSource2")
  private MessageSource queueSource2;
  
  @MockBean(name = "queueSource3")
  private MessageSource queueSource3;
  
  .. and so on
  </code></pre>
  
  <p>I tried to Mock all MessageSources, or all JmsDestinationPollingSource's but that seems hard (I read about PowerMockito but didn't try it out yet because I think it can be done differently).</p>
  
  <p>I thought that it should also be possible to disable the Poller in the test scope. 
  I suppose there are more solutions to my problem that I didn't think of.
  All help is appreciated!</p>