Skip to content

Instantly share code, notes, and snippets.

@Gems
Last active July 12, 2022 11:36
Show Gist options
  • Save Gems/7555776feae619ac71ed8d9dd9d4d33e to your computer and use it in GitHub Desktop.
Save Gems/7555776feae619ac71ed8d9dd9d4d33e to your computer and use it in GitHub Desktop.
Camel onCompletion weird behavior — Unit Test
package camel.test;
import lombok.SneakyThrows;
import lombok.val;
import org.apache.camel.EndpointInject;
import org.apache.camel.Produce;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.junit5.CamelTestSupport;
import org.junit.jupiter.api.Test;
public class TestTest extends CamelTestSupport {
@EndpointInject(uri = "mock:end")
protected MockEndpoint endEndpoint;
@Produce(uri = "direct:a")
protected ProducerTemplate template;
@Test
@SneakyThrows
public void test() {
val body = "<body>";
endEndpoint.expectedBodiesReceived(body);
template.sendBody(body);
endEndpoint.assertIsSatisfied();
}
@Override
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
from("direct:a")
.onCompletion().log("a - done").end()
.to("seda:b");
from("seda:b")
.onCompletion().log("b - done").end()
.to("seda:c");
from("seda:c")
.onCompletion().log("c - done").end()
.to("seda:d");
from("seda:d")
.onCompletion().log("d - done").end()
.to("mock:end");
}
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment