繁体   English   中英

如何同时提出休息请求

[英]How to make concurrent rest requests

嗨,我正在尝试编写一个集成测试,该测试将进行并发(例如说3个并发)宁静的api调用,并且我需要断言在每次调用中返回的数据都是不同的。 这是因为我在一个同步块中具有查找,更新和返回数据的功能,因此我需要测试每个线程返回的数据是否不同。 我查看了junit activetestsuite,但不确定如何将其应用于集成测试。 我想在IT测试中进行的API调用如下

  ResponseEntity<String> response = this.restTemplate
                .exchange("endpoint/",HttpMethod.GET,String.class);

 //make assertions on each returned call

也许看看Java的ReactiveX zip方法:

http://reactivex.io/documentation/operators/zip.html

假设您要同时运行UnitTest。 并发JUnit可以对此提供帮助。 https://github.com/ThomasKrieger/concurrent-junit此处还有分步指南: https : //examples.javacodegeeks.com/core-java/junit/junit-multithreaded-test-example /

希望对您有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM