title: Spring rabbitmq testing - RabbitListenerTestHarness doesn't find any listener
body: <p>I'm trying to write some tests for a spring rabbitmq application.</p>
  
  <p>From <a href="http://docs.spring.io/spring-amqp/docs/1.6.1.RELEASE/reference/html/_reference.html#testing" rel="nofollow">documentation</a>, I found the example using RabbitListenerTestHarness.</p>
  
  <p>I created a Test in spring that looks like:</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @SpringApplicationConfiguration(classes = MyMain.class)
  public class MyClassTest {
  
      @Test
      public void myTest(){
          RabbitProperties.Listener listener = harness.getSpy("test_consumer2");
      }
  }
  </code></pre>
  
  <p>In the source, I have a bean that creates the configuration to rabbitmq which has the annotation <code>@RabbitListenerTest(capture = true, spy = true)</code>.</p>
  
  <p>Also, in the source I have the following consumer:</p>
  
  <pre><code>@Component
  </code></pre>
  
  <p>public class TestConsumerStub {</p>
  
  <pre><code>@RabbitListener(
          id = "test_consumer2",
          queues = "my_queue"
  )
  public void testHandler(){
  
  }
  </code></pre>
  
  <p>For some reason, the harness (<code>RabbitListenerTestHarness harness</code>) object from the tests, is not loaded in the context that consumer. The following variable is null:
  <code>RabbitProperties.Listener listener = harness.getSpy("test_consumer2");</code></p>
  
  <p>Any idea what did I missed? </p>