简体   繁体   English

单元测试带有二进制数据的java servlet

[英]unit testing java servlets with binary data

I'm attempting to write a Java Servlet unit test to send binary data http requests to the servlet and receive a binary response. 我正在尝试编写Java Servlet单元测试,以将二进制数据http请求发送到servlet并接收二进制响应。 Usually I use the jetty ServletTester and HttpTester to unit test servlets, but HttpTester doesn't seems to support binary requests yet. 通常我使用jetty ServletTester和HttpTester对servlet进行单元测试,但HttpTester似乎还不支持二进制请求。

Any ideas how can I unit test a binary servlet in java? 任何想法如何在java中单元测试二进制servlet?

Seems in Jetty 8 HttpTester store content in binary format. 似乎Jetty 8 HttpTester以二进制格式存储内容。

You may extend HttpTester and set _genContent manually(it is protected). 您可以扩展HttpTester并手动设置_genContent(它受保护)。 Or you can interpret the bytes as String with the same charset as in HttpTester. 或者您可以使用与HttpTester中相同的字符集将字节解释为String。

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

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