use of com.hotels.styx.InetServer in project styx by ExpediaGroup.
the class MockOriginServer method create.
public static MockOriginServer create(String appId, String originId, int adminPort, HttpConnectorConfig httpConfig) {
WireMockApp wireMockApp = wireMockApp();
InetServer adminServer = createAdminServer(originId, adminPort, wireMockApp);
InetServer mockServer = HttpServers.createHttpServer("mock-stub-" + originId, httpConfig, mockHandler(originId, wireMockApp, new WireMockConfiguration()));
int serverPort = httpConfig.port();
return new MockOriginServer(appId, originId, adminPort, serverPort, adminServer, mockServer);
}
use of com.hotels.styx.InetServer in project styx by ExpediaGroup.
the class MockOriginServer method create.
public static MockOriginServer create(String appId, String originId, int adminPort, HttpsConnectorConfig httpsConfig) {
WireMockApp wireMockApp = wireMockApp();
InetServer adminServer = createAdminServer(originId, adminPort, wireMockApp);
InetServer mockServer = HttpServers.createHttpsServer("mock-stub-" + originId, httpsConfig, mockHandler(originId, wireMockApp, new WireMockConfiguration()));
int serverPort = httpsConfig.port();
return new MockOriginServer(appId, originId, adminPort, serverPort, adminServer, mockServer);
}
use of com.hotels.styx.InetServer in project styx by ExpediaGroup.
the class StyxProxyTest method startsServerWithHttpConnector.
@Test
public void startsServerWithHttpConnector() {
HttpInterceptor echoInterceptor = (request, chain) -> textResponse("Response from http connector");
StandardHttpRouter handler = new StandardHttpRouter();
InetServer styxServer = newBuilder().setProtocolConnector(connector(0)).bossExecutor(NettyExecutor.create("Test-Server-Boss", 1)).workerExecutor(NettyExecutor.create("Test-Server-Worker", 0)).handler(new HttpInterceptorPipeline(List.of(echoInterceptor), (request, context) -> new HttpAggregator(new StandardHttpRouter()).handle(request, context), false)).build();
Service server = StyxServers.toGuavaService(styxServer);
server.startAsync().awaitRunning();
assertThat("Server should be running", server.isRunning());
HttpResponse secureResponse = get("http://localhost:" + styxServer.inetAddress().getPort());
assertThat(secureResponse.bodyAs(UTF_8), containsString("Response from http connector"));
server.stopAsync().awaitTerminated();
assertThat("Server should not be running", !server.isRunning());
}
Aggregations