java - Spring Cloud Stream Test 在消息的有效负载中硬编码“Hello World”
问题描述
我正在尝试 Spring Cloud Stream,当我尝试运行最简单的测试之一时(原始测试可在此处获得:https ://github.com/spring-cloud/spring-cloud-stream/blob/master/spring- cloud-stream-test-support/src/test/java/org/springframework/cloud/stream/test/disable/AutoconfigurationDisabledTest.java )
使用:Java 1.8 SpringBoot 2.1.5.RELEASE spring-cloud.version:Greenwich.RELEASE
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@DirtiesContext
public class ExampleTest {
@Autowired
public MessageCollector messageCollector;
@Autowired
public Processor processor;
@SuppressWarnings("unchecked")
@Test
public void testAutoconfigurationDisabled() {
this.processor.input().send(MessageBuilder.withPayload("empty").build());
Message<String> response = (Message<String>) this.messageCollector.forChannel(this.processor.output()).poll();
Assertions.assertThat(response).isNotNull();
Assertions.assertThat(response.getPayload()).isEqualTo("Hello World");
}
}
测试通过了,但不应该。消息以“空”发送,这就是我希望收到的,但接收到的有效负载始终是“Hello World”
解决方案
从“Hello world”更改为“”后,请确保您已经编译了您的测试类。当我将 maven 与 Intellij 一起使用并从 maven 视图运行测试时,我遇到了未编译的测试类的情况,并且总是得到以前的结果。
推荐阅读
- python - Django-Rest-Framework Serializer 验证数据返回无
- conv-neural-network - 空间变换网络如何学习适当地变换图像?
- javascript - 不能 app.use 在我的 index.js 文件中使用两个不同的路由器
- python - Pandas:使用 loc 将一行布尔值附加到 df 更改为 int
- sql - 查询以查找要聚合的不同字符串
- javascript - 检查用户和机器人角色是否高于提到的用户(discord.js)
- android - 使用 PassportJS 响应本机社交登录
- ios - Apple Silicon M1 Mac Mini 上的 Flutter:iOS SIM 错误
- scala - 杰克逊用 $ 符号读取节点字段
- npm - 为什么每次我使用 npm 或 yarn 安装包时,它都会安装所有依赖项?