fix failed testSSLConnectionFailsIfOnlyHttpConfigured

This commit is contained in:
korlov42 2020-10-09 23:25:48 +03:00 committed by Andrew Gaul
parent d74dcca6dd
commit d7897b3d25
1 changed files with 11 additions and 1 deletions

View File

@ -24,6 +24,7 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import java.io.Closeable;
import java.io.IOException;
import java.util.List;
import java.util.Properties;
@ -167,7 +168,7 @@ public class OkHttpCommandExecutorServiceTest extends BaseHttpCommandExecutorSer
}
}
@Test(expectedExceptions = HttpResponseException.class, expectedExceptionsMessageRegExp = "Failed to connect to.*")
@Test(expectedExceptions = HttpResponseException.class, expectedExceptionsMessageRegExp = "Unable to find acceptable protocols.*")
public void testSSLConnectionFailsIfOnlyHttpConfigured() throws Exception {
MockWebServer server = mockWebServer(new MockResponse());
server.useHttps(sslSocketFactory(), false);
@ -231,6 +232,15 @@ public class OkHttpCommandExecutorServiceTest extends BaseHttpCommandExecutorSer
}
}
protected static MockWebServer mockWebServer(MockResponse... responses) throws IOException {
MockWebServer server = new MockWebServer();
server.start(null, 0);
for (MockResponse response : responses) {
server.enqueue(response);
}
return server;
}
@ConfiguresHttpCommandExecutorService
private static final class ConnectionSpecModule extends AbstractModule {
private final List<ConnectionSpec> connectionSpecs;