代码之家  ›  专栏  ›  技术社区  ›  Jav

Wire Mock:HTTP方法修补程序不支持输出

  •  1
  • Jav  · 技术社区  · 6 年前

    尝试使用wire mock模拟restapi补丁

    public void mockPersonUpdateService() throws IOException {
        stubFor(patch(urlMatching(".*/person-service-web/v1/person/*\\?access_token=38a307c9-487b-402a-bb32-83bacd53bcc1")).willReturn(aResponse().withHeader(
                    "Content-Type", "application/json").withStatus(200).withBody(IOUtils.toString(getClass().getClassLoader().getResourceAsStream(
                                "json/peroson.update.json.response")))));
    
    }
    

    运行测试用例时出现以下异常:

    原因:java.net.ProtocolException:HTTP方法修补程序没有 支持输出 太阳网.协议.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1081) org.glassfish.jersey网站.client.internal.HttpUrlConnector$4.getOutputStream(HttpUrlConnector.java:385) 在 org.glassfish.jersey网站.message.internal.CommittingOutputStream.commitStream公司mmittingOutputStream.java:200) 在 org.glassfish.jersey网站.message.internal.CommittingOutputStream.commitStream公司mmittingOutputStream.java:194) 在 org.glassfish.jersey网站.message.internal.CommittingOutputStream.写入(CommittingOutputStream.java:243) com.ctlts.vantive公司.服务.公共.休息.client.AbstractJerseyLoggingFilter$日志流.write(Abstrac公司tJerseyLoggingFilter.java:294) org.glassfish.jersey网站.message.internal.WriterInterceptorExecutor$UnC美元LosableOutputStream.write(写下rInterceptorExecutor.java:299) 在 com.fasterxml.jackson网站.core.json.UTF8JsonGenerator.\u冲洗缓冲区(UTF8JsonGenerator.java:1853) 在 在 org.glassfish.jersey网站.message.internal.WriterInterceptorExecutor$Termi公司nalWriterInterceptor.invokeWriteTo(写下rInterceptorExecutor.java:265) org.glassfish.jersey网站.message.internal.WriterInterceptorExecutor$Termi公司nalWriterInterceptor.aroundWriteTo(写下rInterceptorExecutor.java:250) 在 org.glassfish.jersey网站.message.internal.WriterInterceptorExecutor.继续(写入rInterceptorExecutor.java:162) com.ctlts.vantive公司.服务.公共.休息.client.AbstractJerseyLoggingFilter.aroundWriteTo(文章摘要)tJerseyLoggingFilter.java:259) org.glassfish.jersey网站.message.internal.WriterInterceptorExecutor.继续(写入rInterceptorExecutor.java:162) 在 org.glassfish.jersey网站.message.internal.MessageBodyFactory.writeTo公司(MessageBodyFactory.java:1130) 在 org.glassfish.jersey网站.client.ClientRequest.doWriteEntity(ClientRequest.java:517) 在 在 org.glassfish.jersey网站.client.internal.HttpUrlConnector.\u申请(HttpUrlConnector.java:388) 在 ... 57个以上

    0 回复  |  直到 6 年前