我有一个集成测试,检查响应的内容类型如下匹配器断言上两个对象
Header header = new BasicHeader("Content-Type", "application/octet-stream; charset=UTF-8");
assertThat(response.getEntity().getContentType(), Matchers.is(header));
测试失败断言响应是相同的像与该奇数消息
预构建头Expected: is <Content-Type: application/octet-stream; charset=UTF-8>
but: was <Content-Type: application/octet-stream; charset=UTF-8>
我的预感是因为我们讲的是两个对象,所以我们讲的是两个不同的实例。为了这个,我也试着
assertThat(response.getEntity().getContentType(), Matchers.equalTo(header));
但结果是一样的。
任何想法我做错了什么?
response.getEntity()。getContentType()的返回类型是否实现'equals'? –
@StefanBirkner该方法返回apache.httpcomponets包的BasicHeader。从我的调查来看,这已经等同实施。有什么想法吗 ? –
哪个版本等于重写? [这一个不。](http://grepcode.com/file/repo1.maven.org/maven2/org.apache.httpcomponents/httpcore/4.4/org/apache/http/message/BasicHeader.java)外观像你可能需要一个自定义的匹配器 – blgt