title: Camel - sending messages to mocked inputs
body: <p>How do I replace a heavy-weight input endpoint with a mock and send a message to it?</p>
  
  <p>Say I have the following route.</p>
  
  <pre><code>from("spring-ws:rootqname:{http://myNameSpace}SomeRequest?endpointMapping=#endpointMapping").
      processor(new VeryComplicatedProcessor()).
      to(etc).
      to(etc)...
  </code></pre>
  
  <p>In other words, a spring web service that does a whole lotta processing.</p>
  
  <p>One way to test this route is to start up the webservice in a webserver and send it a message, but that's a lot more overhead than I'd like to incur.</p>
  
  <p>Instead, I'd expect that if I <a href="http://camel.apache.org/mock.html" rel="nofollow noreferrer">mock all of my endpoints</a>, I should be able to do this:</p>
  
  <pre><code>public class RouteTest extends CamelSpringTestSupport {
  
      @Override
      public String isMockEndpoints() {
          return "*";   // mock everything
      }
  
      @Test
      public void simpleDirectTest() throws Exception {
  
          String realURI = "spring-ws:rootqname:{http://myNameSpace}SomeRequest?endpointMapping=#endpointMapping";
          String mockedURI = "mock:" + realURI;
          String msg = buildSomeSoapMsg();
  
          Object out = template.requestBody(mockedURI, msg);
          log.debug(out.toString());
      }
  ...
  }
  </code></pre>
  
  <p>... and have the entire route run and return the response to me.  Instead though, I just get the message sent right back to me, and the route hasn't been run.</p>
  
  <p>Is my understanding of mocks incorrect?  If so is there an alternative way to achieve this?  I'd really like to avoid having to actually start the webservice to test these routes.</p>
  
  <p>Thanks all.</p>
  
  <p>EDIT - It looked for a minute like I could use <a href="https://stackoverflow.com/questions/5664331/how-to-unit-test-production-routes-in-apache-camel/5665383#5665383">AdviceWith</a> to solve this problem, but AdviceWith only seems to work with outputs, and not inputs as is the case above.</p>