OlegK
OlegK

Reputation: 21

Testing Camel REST component endpoint producer template

I'm trying to rest my route with a new Camel Rest component available from version 2.14 :

@Produce(uri = "rest:test.get/company/{name}")
protected ProducerTemplate testProducer;    

And ProducerTemplate which corresponds to this kind of rest endpoint is basically not yet implemented in that version. What would be the best way to test that kind of endpoints?

Upvotes: 2

Views: 5369

Answers (2)

Marcos Rufino
Marcos Rufino

Reputation: 141

use camel-restlet or HttpClient

**application.properties**

@Produce(uri = "{{url.router}}")
protected ProducerTemplate testProducer;

or

@Produce(uri = "http://localhost:8080/test/router")
protected ProducerTemplate testProducer;
@Test
public void testHttpMock() throws InterruptedException {
    testProducer.requestBodyAndHeader(null, userApi, passwordApi);
    mockEndpoint.expectedMessageCount(1);
    assertMockEndpointsSatisfied();
}

Upvotes: 1

Willem Jiang
Willem Jiang

Reputation: 3291

Current Camel Rest component only work for the Consumer (Server) side. By suggestion is you can use camel-restlet or HttpClient to send the plain HTTP request for testing.

@Produce(uri = "restlet:http://localhost:808/test.get/company/{name}")
protected ProducerTemplate testProducer;

testProducer.requestBodyAndHeader(null, "name", 123, String.class);

Upvotes: 3

Related Questions