【发布时间】:2018-10-30 13:33:01
【问题描述】:
如何为以下 Spring Integration DSL Http.outboundGateway 操作编写 JUnit:
integrationFlowBuilder
.from(integerMessageSource(),
c -> c.poller(Pollers.cron("0 0/1 * 1/1 * ?")
.handle(Http
.outboundGateway("http://localhost:8050/greeting")
.httpMethod(HttpMethod.GET)
.expectedResponseType(String.class))
.channel("getChannel");
flowContext.registration(integrationFlowBuilder.get()).register();
integerMessageSource 方法是
@Bean
private MethodInvokingMessageSource integerMessageSource() {
final MethodInvokingMessageSource source = new MethodInvokingMessageSource();
source.setObject(new AtomicInteger());
source.setMethodName("getAndIncrement");
return source;
}
我想用一些 cron 表达式启动 JUnit,并验证是否调用了 URL“http://localhost:8050/greeting”。最好对 URL http://localhost:8050/greeting 中的服务器进行模拟,以便它响应一些响应。
通过 POST 操作,我想检查一些 JSON 是否发送到 URL http://localhost:8050/greeting。
这可以测试吗?
【问题讨论】:
标签: spring-integration spring-integration-dsl