Contract testing for XML file exchange

泪湿孤枕 提交于 2021-01-29 21:15:46

问题


We use pact contract tests for services that communicate using rest calls and kafka messages. We would also like to implement a similar contract testing framework between services that exchange (xml) files via an sftp server. I might be able to use the message pact framework and treating the contents of the file as the contents of the message, but was wondering if there were better alternatives. No matter how I handle contract testing between a consumer and producer that exchange files, I will also have to deal with how to validate xml code, so any advice on that would also be appreciated.


回答1:


The Pact framework does not impose any restriction on the contents of interactions that are verified. You can use it with XML, or any other type of data. The main thing with JSON is there is good DSL support for defining the contract for a JSON payload. With other types of data, the support is not so good. We've started adding DSL support for XML, but it is still early days for it.

You can treat your files just like asynchronous messages, where the transport mechanism is an SFTP site. It would be possible to use the Message Pact format to then create contract tests for these. Your provider would be whatever writes the file to the server, and the consumer is what reads it. The contract would be between these two systems, and you can abstract away that the XML files are transferred via an SFTP server.

For your particular case, however, I wonder if using XSDs to verify the files would be sufficient?



来源:https://stackoverflow.com/questions/61346039/contract-testing-for-xml-file-exchange

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!