@Before public void setUp() throws Exception { log.debug("Test: " + testName.getMethodName()); client = OkHttpUnsafe.getUnsafeClient() .newBuilder() .protocols(Arrays.asList(Protocol.HTTP_2, Protocol.HTTP_1_1)) .build(); TlsConfig tlsConfig = TlsConfig.builderFrom(ConfigFactory.load().getConfig("xio.h2BackendServer.settings.tls")) .build(); server = OkHttpUnsafe.getSslMockWebServer(getKeyManagers(tlsConfig)); server.setProtocols(Arrays.asList(Protocol.HTTP_2, Protocol.HTTP_1_1)); server.start(); }
@Before public void setUp() throws Exception { reportedSpans = new ArrayList<>(); TlsConfig tlsConfig = TlsConfig.builderFrom(ConfigFactory.load().getConfig("xio.h2BackendServer.settings.tls")) .build(); server = OkHttpUnsafe.getSslMockWebServer(getKeyManagers(tlsConfig)); server.setProtocols(Collections.singletonList(Protocol.HTTP_1_1)); server.enqueue(buildResponse()); server.start(); }
@Before public void setUp() throws Exception { TlsConfig tlsConfig = TlsConfig.builderFrom(ConfigFactory.load().getConfig("xio.testServer.settings.tls")) .build(); client = OkHttpUnsafe.getUnsafeClient(); server = OkHttpUnsafe.getSslMockWebServer(getKeyManagers(tlsConfig)); server.start(); }
@Test public void testConnectingSuccessfulConnection() throws Exception { // set up fake origin backend server so we can connect to it, we connect to port 8888 // the outbound 8888 is specified in the ClientConnectionManagerIntegrationTest.conf TlsConfig tlsConfig = TlsConfig.builderFrom(ConfigFactory.load().getConfig("xio.h2BackendServer.settings.tls")) .build(); server = OkHttpUnsafe.getSslMockWebServer(TlsHelper.getKeyManagers(tlsConfig)); server.setProtocols(Arrays.asList(Protocol.HTTP_2, Protocol.HTTP_1_1)); // tell the server to bind to 8888 server.start(8888); subject = subjectFactory(true); Future<Void> connectionResult = subject.connect(); assertEquals(ClientConnectionState.CONNECTING, subject.connectionState()); Thread.sleep(100); // todo: (WK) do something smarter try { connectionResult.get(5, TimeUnit.SECONDS); } catch (Exception e) { System.out.println("Connection exception = " + e.toString()); } finally { assertEquals(ClientConnectionState.CONNECTED, subject.connectionState()); server.close(); } }
OkHttpUnsafe.getSslMockWebServer( getKeyManagers(tlsConfig.getPrivateKey(), tlsConfig.getCertificateAndChain())); server.setProtocols(protocols);