Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
跟踪输入和输出;Spring集成的消息通道输出_Spring_Spring Mvc_Junit_Spring Integration - Fatal编程技术网

跟踪输入和输出;Spring集成的消息通道输出

跟踪输入和输出;Spring集成的消息通道输出,spring,spring-mvc,junit,spring-integration,Spring,Spring Mvc,Junit,Spring Integration,我已经使用Spring集成构建了一个小应用程序。我还为更多服务和其他类编写了一些jUnit。 我已经将XML配置用于通道和en-point配置,我想知道是否可以测试特定通道的输入和输出。 有没有办法测试通道的输入和输出 更新 我正在尝试下面的流程。我该怎么办 <int:channel id="getPresciption" /> <int:channel id="respPrescription" /> <int:channel id="storePrcedureC

我已经使用Spring集成构建了一个小应用程序。我还为更多服务和其他类编写了一些jUnit。 我已经将XML配置用于通道和en-point配置,我想知道是否可以测试特定通道的输入和输出。 有没有办法测试通道的输入和输出

更新

我正在尝试下面的流程。我该怎么办

<int:channel id="getPresciption" />
<int:channel id="respPrescription" />
<int:channel id="storePrcedureChannell" />

<int-http:inbound-gateway
    request-channel="getPresciption" reply-channel="respPrescription"
    supported-methods="GET" path="/getAllPresciption">

    <int-http:request-mapping
        consumes="application/json" produces="application/json" />
</int-http:inbound-gateway>

<int:service-activator
    ref="prescriptionServiceActivator" method="buildPrescription"
    input-channel="getPresciption" output-channel="storePrcedureChannell" />

<int:service-activator
    ref="prescriptionServiceActivator" method="storePrescription"
    input-channel="storePrcedureChannell"></int:service-activator>

那么如何编写测试上下文呢

下面是通道流调用的方法

public Message<List<Prescription>> buildPrescription() {
  //Do some processing
}

public Message<List<Prescription>> storePrescription(Message<List<Prescription>> msg) {

  //Do something and return the List.
}
public Message buildPrescription(){
//做一些处理
}
公共消息存储(消息消息消息){
//做点什么,然后返回列表。
}

首先,您可以了解Spring集成测试框架:

然后使用
MockIntegration.mockMessageHandler()
MockIntegrationContext.substituteMessageHandlerFor()
替换端点中的实际处理程序,并验证来自通道的传入数据


如果这对您来说仍然很困难,您总是可以将这些通道注入到测试类中,并向它们添加一个
ChannelInterceptor
,并在其
preSend()
实现中验证消息。

我正期待您的回复。几天前,我看到了您为spring集成进行单元测试的Gut存储库代码。我也是测试频道的人。这就是我要走的路吗?很好。有帮助吗?你已经能接受答案了吗?或者你还有其他疑问吗?我会写一些测试用例,并在这里发布。是的,这些都是有帮助的。我正在关注这些。让我们看看我是否可以做到这一点没有任何问题。我是按照这个链接。我们必须为每个通道的测试创建xml吗?我必须在更新的部分中为流编写测试用例。