2 Replies Latest reply on Jul 6, 2011 3:50 AM by Richard Tomlinson

    Testing InOut route with a <to> in the middle...

    Richard Tomlinson Newbie

      I have a problem testing a route.   Its Spring wired in its own xml file with the actuals endpoints wired in another xml file and accessed through vm endpoints. The route is something like:

       

                ... etc the response I'm looking for...";

       

          @Test

          public void shouldExcersiseRoute() throws Exception {

       

              mockSearchEndpoint.whenAnyExchangeReceived(

                      new Processor() {

                          @Override

                          public void process(Exchange exchange) {

                              exchange.getOut().setBody(new ByteArrayInputStream(resp

                                      .getBytes()));

                          }

                      });

       

              Object body = new MessageContentsList(new DOMSource(getDocument(msg)));

              Object response = template.requestBody(body);

       

              assertEquals("...Assert the response is found...", response);

       

          }

       

          private Document getDocument(String xml) throws Exception {

              DocumentBuilderFactory factory =

                      DocumentBuilderFactory.newInstance();

              factory.setNamespaceAware(true);

              InputSource source = new InputSource(new StringReader(xml));

              DocumentBuilder docBuilder = factory.newDocumentBuilder();

              Document doc = docBuilder.parse(source);

              return doc;

          }

       

       

      I can see when debugging that the processor for the vm:restQuery is called but I never get a response from the .requestBody with the test eventually timing out.

       

      How does one go about testing a route where it interacts with other end points before sending the response?   Is my approach correct but I'm missing something on the interaction with vm:restQuery?

       

      Thanks