Wire Mock:HTTP方法PATCH不支持输出

时间:2018-08-02 11:35:26

标签: rest selenium jersey wiremock

尝试使用Wire Mock模拟剩余api PATCH

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方法PATCH没有   支持输出   sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1081)   在   org.glassfish.jersey.client.internal.HttpUrlConnector $ 4.getOutputStream(HttpUrlConnector.java:385)   在   org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:200)   在   org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:194)   在   org.glassfish.jersey.message.internal.CommittingOutputStream.write(CommittingOutputStream.java:243)   在   com.ctlts.vantive.services.common.rest.client.AbstractJerseyLoggingFilter $ LoggingStream.write(AbstractJerseyLoggingFilter.java:294)   在java.io.FilterOutputStream.write(FilterOutputStream.java:125)在   org.glassfish.jersey.message.internal.WriterInterceptorExecutor $ UnCloseableOutputStream.write(WriterInterceptorExecutor.java:299)   在   com.fasterxml.jackson.core.json.UTF8JsonGenerator._flushBuffer(UTF8JsonGenerator.java:1853)   在   com.fasterxml.jackson.core.json.UTF8JsonGenerator.flush(UTF8JsonGenerator.java:1034)   在   com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:462)   在   com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider.writeTo(JacksonJsonProvider.java:583)   在   org.glassfish.jersey.message.internal.WriterInterceptorExecutor $ TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:265)   在   org.glassfish.jersey.message.internal.WriterInterceptorExecutor $ TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:250)   在   org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)   在   com.ctlts.vantive.services.common.rest.client.AbstractJerseyLoggingFilter.aroundWriteTo(AbstractJerseyLoggingFilter.java:259)   在   org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.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.ClientRequest.writeEntity(ClientRequest.java:499)   在   org.glassfish.jersey.client.internal.HttpUrlConnector._apply(HttpUrlConnector.java:388)   在   org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:285)   ...还有57个

0 个答案:

没有答案