1

I have camel route as below

public class IncomingBatchFileRoute extends RouteBuilder {

    @Value(CCS_PROCESSING_INCOMING_DIRECTORY)
    private String source;


    @Override
    public void configure() throws Exception {
        from(sourceLocation)).autoStartup(false).to("encryptionEndPoint");
    }

}

I need to write a JUNIT For above camel route and am new to it and created a structure as below

public class IncomingBatchFileRouteTest extends CamelTestSupport{


    @Override
    public RoutesBuilder createRouteBuilder() throws Exception {
        return new IncomingBatchFileRoute();
    }

    @Test
    public void sampleMockTest() {

    }
}

Not sure how to complete it. Request you to help me on this

rocky
  • 753
  • 2
  • 10
  • 26

1 Answers1

0

You need to mock your encryptionEndPoint and start your route with a producerTemplate

@Produce(uri = CCS_PROCESSING_INCOMING_DIRECTORY)
protected ProducerTemplate template;

@EndpointInject(uri = "encryptionEndPoint")
protected MockEndpoint resultEndpoint;

@Test
public void sampleMockTest() {

  // GIVEN
  this.resultEndpoint.expectedMessageCount(1);

  // WHEN
  this.template.sendBody("Hey");

  // THEN
  this.resultEndpoint.assertIsSatisfied();
}
Thomas
  • 1,008
  • 3
  • 16
  • 34