我想在该模式下使用MockServer 分析dumpToLogAsJava
,让它打印我拥有的 HTTP 服务的 java 格式期望。
此外,我想使用 mockserver-maven-plugin 。
到目前为止,我能够得到这样的 json 格式的输出:
2016-06-07 19:10:46,348 DEBUG [main] org.mockserver.cli.Main [?:?]
Using command line options: proxyPort=18080
2016-06-07 19:10:46,623 INFO [MockServer HttpProxy Thread] org.mockserver.proxy.http.HttpProxy [?:?] MockServer proxy started on port: 18080
2016-06-07 19:10:46,626 DEBUG [MockServer HttpProxy Thread] o.m.c.ConfigurationProperties [?:?] Property file not found on classpath using path [mockserver.properties]
2016-06-07 19:10:46,626 DEBUG [MockServer HttpProxy Thread] o.m.c.ConfigurationProperties [?:?] Property file not found using path [mockserver.properties]
2016-06-07 19:11:01,838 DEBUG [nioEventLoopGroup-3-1] o.m.client.netty.NettyHttpClient [?:?] Sending request: {
"method" : "GET",
"path" : "/sources",
[...]
}
2016-06-07 19:11:02,180 DEBUG [nioEventLoopGroup-3-1] o.m.client.netty.NettyHttpClient [?:?] Received response: {
[...]
}
2016-06-07 19:11:02,220 INFO [nioEventLoopGroup-3-1] o.m.proxy.http.HttpProxyHandler [?:?] returning response:
{
[...]
}
for request as json:
{
[...]
}
as curl:
[...]
通过将以下内容添加到我的pom.xml
<plugin>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-maven-plugin</artifactId>
<version>3.10.4</version>
<configuration>
<proxyPort>18080</proxyPort>
<logLevel>DEBUG</logLevel>
</configuration>
<executions>
<execution>
<id>start-mock</id>
<phase>pre-integration-test</phase>
<goals>
<goal>runForked</goal>
</goals>
</execution>
<execution>
<id>stop-mock</id>
<phase>post-integration-test</phase>
<goals>
<goal>stopForked</goal>
</goals>
</execution>
</executions>
</plugin>
我不知道如何在不编写一些额外的 Java 代码的情况下将输出格式更改为 Java(即使这样我也不确定我到底要写什么)。
PS。我似乎根本无法获得 Java 格式的转储——我在GH上填写了一个问题