// Mock and skip result endpoint
mockEndpointsAndSkip("log:*");
}
});
MockEndpoint resultEndpoint = context.getEndpoint("mock:log:foo", MockEndpoint.class);
// resultEndpoint.expectedMessageCount(1); // If you want to just check the number of messages
resultEndpoint.expectedBodiesReceived("hello"); // If you want to check the contents
// You can also take the expected result from an external file
// String result = IOUtils.toString(context.getClassResolver().loadResourceAsStream("testdata/out/result.txt"));
// resultEndpoint.expectedBodiesReceived(result.replaceAll("\r?\n", "\n"));
// Start the integration
integration.run();
// Send the test message
context.createProducerTemplate().sendBody("direct:start", "hello");
// You can also send an external file
// context.createProducerTemplate.sendBody("direct:start", context.getClassResolver().loadResourceAsStream("testdata/in/input.xml"));
// REST/HTTP services can be easily tested with RestAssured:
// get(context.resolvePropertyPlaceholders("{{restUrl}}")).then().statusCode(204).body(isEmptyOrNullString());
// given().param("status").get(context.resolvePropertyPlaceholders("{{restUrl}}")).then().statusCode(200).body(equalTo("active"));
// given().auth().basic("testuser", "testpass").body("hello").when().post(context.resolvePropertyPlaceholders("{{restUrl}}")).then().statusCode(200).body(equalTo("response"));
resultEndpoint.assertIsSatisfied();
}