mardi 5 juillet 2016

JUnit test a route

I have gone through numerous articles but couldn't relate to any of them so I'm asking this question.

I have a route defined as follows:

<bean id="GetNewRows" class="FileRead"/>

<route>
      <from uri="timer://myTimer?period=1m"/> <!--executes a timer every minute -->
      <process ref="GetNewRows"/>  <!--implements a processor that returns a string -->
      <to uri="activemq:myQueue"/>  <!-- posts the string to a queue.--> 
</route>

The processor is implemented in the class FileRead as

public void process(Exchange exchange) throws Exception {

        String newRows = GetNewlyAddedRows();

        exchange.getIn().setBody(newRows);

}

I can test GetNewlyAddedRows() just fine in Junit.

My question is how do I test the above route in JUnit ?

Aucun commentaire:

Enregistrer un commentaire