Boa tarde, Estou fazendo testes com o camel + springboot e estou tendo problemas com o json-validator
no repo oficial da apache (https://github.com/apache/camel) tem exemplos que nao estão rodando.
basicamente ele não executa a validacação de schema do Json como faz com o SOAP, alguém tem alguam ideia?
att,
public class CamelJsonTest extends CamelTestSupport {
@EndpointInject(uri = "mock:valid")
protected MockEndpoint validEndpoint;
@EndpointInject(uri = "mock:finally")
protected MockEndpoint finallyEndpoint;
@EndpointInject(uri = "mock:invalid")
protected MockEndpoint invalidEndpoint;
@Test
public void schemaTest() throws Exception {
validEndpoint.expectedMessageCount(1);
finallyEndpoint.expectedMessageCount(1);
String body = "{\"codigo\": \"a\",\"codigoRecaudador\": \"b\",\"codigoCanal\": \"c\",\"numeroPagina\": 1,\"cantidadRegistros\": 2,\"authorization\": \"d\"}";
String header = "{}";
template.sendBodyAndHeader("direct:test", body, "header", header);
MockEndpoint.assertIsSatisfied(validEndpoint, invalidEndpoint, finallyEndpoint);
}
@Test(expected = ValidationException.class)
public void schema2Test() throws Exception {
validEndpoint.expectedMessageCount(1);
finallyEndpoint.expectedMessageCount(1);
String body = "{}";
String header = "{}";
template.sendBodyAndHeader("direct:test", body, "header", header);
MockEndpoint.assertIsSatisfied(validEndpoint, invalidEndpoint, finallyEndpoint);
}
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:test")
.doTry()
.to("json-validator:org/apache/camel/component/jsonvalidator/schema.json")
.to("mock:valid")
.doCatch(ValidationException.class)
.to("mock:invalid")
.doFinally()
.to("mock:finally")
.end();
}
};
}
}