简体   繁体   English

Java中的单元测试代理代码

[英]Unit-test proxy code in Java

We want to unit-test http-proxy related code. 我们要对与http-proxy相关的代码进行单元测试。 Is there a Java package which can simulate a http proxy? 是否有可以模拟http代理的Java包?

Unit tests should be as simple as possible. 单元测试应尽可能简单。 Instead of testing against a real proxy, record the data streams which you get against a real proxy. 记录针对真实代理的数据流,而不是针对真实代理进行测试。 Save those in strings or files and then run your unit tests against those. 将它们保存在字符串或文件中,然后对它们进行单元测试。

The JMeter Library has got a http proxy server you can use in several ways. JMeter Library拥有一个http代理服务器,您可以通过多种方式使用它。 We use it for exactly the same thing you want to do. 我们将其用于您想要做的完全相同的事情。

http://jmeter.apache.org/ http://jmeter.apache.org/

Ignore the graphical interface if you want to automate the test. 如果要自动化测试,请忽略图形界面。

Regards. 问候。

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

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