title: How to test REST endpoint when using callbacks using JAVA?
body: <p>I want to write some test against an REST endpoint which is using a callback parameter. Might sound confusing so here's an explanation:</p>
  
  <ul>
  <li><p>first call is a POST to <code>/publish</code> with the payload:</p>
  
  <p><code>{"callbackURL":"http://localhost:609/test"}</code></p></li>
  <li><p>server replies with 200 and some json</p></li>
  <li><p>the server does an async POST to <code>http://localhost:609/test/status</code> (based on the provided callback URL), with some json payload</p></li>
  </ul>
  
  <p>I built a test using TestNG and Rest-assured (not mandatory). My problem is how to validate both the initial reply and the message received at the callback URL. 
  A (maybe naive) approach I first thought of is to implement a HTTP server which listens at <code>http://localhost:609/test/status</code>, when something comes it writes to a synchronized object from which the test reads and validates. However, sounds a bit tricky (the test local server will use an inner class, etc.) and fragile. Can anyone think of a better approach?</p>