title: How to wait for @JMSListener annotated method to complete in JUnit
body: <p>So I am trying to get some integration testing of JMS processing, Spring (v4.1.6) based code. </p>
  
  <p>It's a very standard Spring setup with <code>@JmsListener</code> annotated method and a <code>DefaultMessageListenerContainer</code> with <code>concurrency</code> set to <code>1</code> and therefore allowing only 1 listening thread. </p>
  
  <p>Now, I leveraged ActiveMQ's embedded broker not to rely on any external jms broker for the tests to run anywhere anytime (I should work in marketing).</p>
  
  <p>So it all wires fine and then I have my JUnit test:</p>
  
  <pre><code>@Test
  public void test() {
      sendSomeMessage();
      //how to wait here for the @JMSListener method to complete
      verify();
  }
  </code></pre>
  
  <p>I send the message, but then I need to somehow wait for the <code>@JMSListener</code> annotated method to complete. How do I do this?</p>