我看到 JDK9 中支持预告片(该HttpResponse.trailers\xe2\x80\x8b()方法),但在 JDK 10 上不再支持(该HttpResponse.trailers\xe2\x80\x8b()方法不存在)。
我目前正在使用 JDK11,当我尝试我的请求时:
\nHttpRequest request = HttpRequest.newBuilder()\n .uri(uri)\n .GET()\n .build();\n\n\nHttpResponse<String> response = httpClient.send(request, BodyHandlers.ofString());\nRun Code Online (Sandbox Code Playgroud)\n我面对一个java.util.concurrent.ExecutionException: java.io.IOException: no statuscode in response. 仅当我请求带有预告片标题的页面时,它才会失败。\n欢迎任何帮助。谢谢
我使用 TestNG 进行单元测试,并尝试将其迁移到 JUnit Jupiter (JUnit 5),我想知道哪种方法是最好的:
测试NG:
@DataProvider
public Object[][] invalidPortNumbers() {
return new Object[][] {
{ "--http", "" },
{ "--http", "-42" },
{ "--http", "0" },
{ "--http", "not_a_port_number" },
{ "--https", "67000" }
};
}
@Test(dataProvider = "invalidPortNumbers",
expectedExceptions = ParameterException.class,
expectedExceptionsMessageRegExp = ".* is not valid port number .*")
public void shouldFailToValidatePortNumber(final String... args) {
new CommandLineParser(args);
}
Run Code Online (Sandbox Code Playgroud)
我看到迁移到JUnit Jupiter,我可以这样做:
static Stream<Arguments> invalidPortNumbers2() {
return Stream.of(
Arguments.of((Object) new String[] { "--http", "-42" …Run Code Online (Sandbox Code Playgroud)