Spring integration Wiremock和Spring集成

Spring integration Wiremock和Spring集成,spring-integration,spring-test,spring-restcontroller,wiremock,Spring Integration,Spring Test,Spring Restcontroller,Wiremock,我在Spring集成中有一个流程,它的工作原理如下 从MQ读取-->执行消息转换-->将转换后的消息发送到Api 现在在我的集成测试中,我试图模仿Api,我尝试了两种风格,但没有成功 以下是关于Wiremock味道的测试(也发布在) 我的失败是 com.github.tomakehurst.wiremock.client.VerificationException:任何存根映射都无法匹配请求。最近的存根映射为:应为:< 邮递 /pa/his/v1/ev>但是:< 邮递 /pa/his/v1/ev

我在Spring集成中有一个流程,它的工作原理如下

从MQ读取-->执行消息转换-->将转换后的消息发送到Api

现在在我的集成测试中,我试图模仿Api,我尝试了两种风格,但没有成功

以下是关于Wiremock味道的测试(也发布在)

我的失败是

com.github.tomakehurst.wiremock.client.VerificationException:任何存根映射都无法匹配请求。最近的存根映射为:应为:< 邮递 /pa/his/v1/ev>但是:< 邮递 /pa/his/v1/ev>

下面是对Spring的MockRestServiceServer的测试

@Before
public void setup() throws PdsListenerException, URISyntaxException {       

    mockServer = MockRestServiceServer.createServer(restTemplate);

}

@Test
public void test_001_success() throws InterruptedException, JSONException, URISyntaxException {
    rNumber = TestUtil.generateRNumber();

    String requestBody = TestUtil.createSampleInputMessage(rNumber);



    mockServer.expect(once(), requestTo("http://localhost:9966" + TestUtil.EVENT_URL))
        .andRespond(withCreatedEntity(new URI(TestUtil.EVENT_URL)));



    sendToJmsOutChannel.send(MessageBuilder.withPayload(TestUtil.createSampleInputMessage(rNumber)).build());


    mockServer.verify();


}
我的失败是

java.lang.AssertionError:预期会有更多请求,但仍有1个未满足预期。 已执行0个请求


我不知道为什么匹配失败。有没有人能指出我应该看的地方。

实际上发现了WireMock的问题所在,我将使用这种味道

我需要改变的是

    @ClassRule
public static WireMockClassRule wireMockRule = new WireMockClassRule(9966);

@Rule
public WireMockClassRule instanceRule = wireMockRule;

...

instanceRule.stubFor(post(urlPathEqualTo(Constants.EVENT_URL))

...
 instanceRule.verify(1, postRequestedFor(urlEqualTo(TestUtil.EVENT_URL)));
基本上使用WireMockRule的实例进行存根和验证,而不是像我以前所做的那样

stubFor(post(urlEqualTo(TestUtil.EVENT_URL))

可能是
restemplate.getForEntity(“http://localhost:9966“+TestUtil.EVENT\u URL)
?我实际上是为了调试目的添加了它…删除了它仍然没有luckOk。你介意和我们分享整个测试吗。我不熟悉Wiremock,但至少我可以在本地运行测试,以了解帮助伙伴的情况……我找到了答案并将其发布在下面。
stubFor(post(urlEqualTo(TestUtil.EVENT_URL))