michaelin007 2024-02-07 07:01:48 +00:00
parent f63fbeca4f
commit 8af3dd780f
2 changed files with 4 additions and 6 deletions

View File

@ -20,8 +20,8 @@ public class DynamicRouterBean {
return "mock:directDynamicRouter";
} else if (body.equalsIgnoreCase("seda") && invoked == 1) {
return "mock:sedaDynamicRouter";
} else if (body.equalsIgnoreCase("book") && invoked == 1) {
return "mock:bookDynamicRouter";
} else if (body.equalsIgnoreCase("file") && invoked == 1) {
return "mock:fileDynamicRouter";
}
return null;
}

View File

@ -21,7 +21,6 @@ public class DynamicRouterRouteUnitTest extends CamelTestSupport {
template.send("direct:dynamicRouter", exchange -> exchange.getIn()
.setBody("mock"));
context.start();
MockEndpoint.assertIsSatisfied(context);
}
@ -45,18 +44,17 @@ public class DynamicRouterRouteUnitTest extends CamelTestSupport {
template.send("direct:dynamicRouter", exchange -> exchange.getIn()
.setBody("seda"));
MockEndpoint.assertIsSatisfied(context);
}
@Test
void givenDynamicRouter_whenMockEndpointExpectedMessageCountOneAndBookAsMessageBody_thenMessageSentToDynamicRouter() throws InterruptedException {
MockEndpoint mockDynamicEndpoint = getMockEndpoint("mock:bookDynamicRouter");
MockEndpoint mockDynamicEndpoint = getMockEndpoint("mock:fileDynamicRouter");
mockDynamicEndpoint.expectedMessageCount(1);
template.send("direct:dynamicRouter", exchange -> exchange.getIn()
.setBody("book"));
.setBody("file"));
MockEndpoint.assertIsSatisfied(context);
}