Open nickmza opened 1 year ago
Interesting piece.
can you please share the link to the source code
@imne can you please share the link to the source code
I can't share this specific code as it's proprietary but would be happy to put an example together for you. Is there anything specific you'd like to see covered?
@nickmza
@imne can you please share the link to the source code
I can't share this specific code as it's proprietary but would be happy to put an example together for you. Is there anything specific you'd like to see covered?
an example would be great :), essentially unit testing a simple rest endpoint in camel mocking out the response of the route, also a soap service mocking out the route and http response
so maybe for something like this:
public class Example extends RouteBuilder {
@Override
public void configure() throws Exception {
from("direct:external-endpoint")
.setHeader("httpClient.soTimeout", constant("{{default.soTimeout}}"))
.setHeader(HTTP_METHOD, constant(HttpMethods.POST))
.setHeader(CONTENT_TYPE, constant(APPLICATION_JSON_VALUE))
.setHeader(ACCEPT, constant(APPLICATION_JSON_VALUE))
.to("https://external.endpoint.com")
.convertBodyTo(String.class)
.log("response = ${body}");
}
}
if I needed to unit test this and have the external endpoint response "to("https://external.endpoint.com")" mocked out.
let's say in this instance the external endpoint being called is "https://dummyjson.com/products/1" with just a get
also for a soap call using cxf endpoint what do those unit tests generally look like and the soap call is using this WSDL http://www.dneonline.com/calculator.asmx?wsdl
@nickmza
@imne can you please share the link to the source code
I can't share this specific code as it's proprietary but would be happy to put an example together for you. Is there anything specific you'd like to see covered?
also what does the method "replaceFromWithMock()" look like and what does it do?
@imne can you please share the link to the source code
Here you go: https://nickmck.net/2023/05/18/camel-simple/
http://localhost:4000/2023/03/31/Apache-Camel/