Search in sources :

Example 1 with ReactorHttpServer

use of org.springframework.cloud.gateway.test.support.ReactorHttpServer in project spring-cloud-gateway by spring-cloud.

the class WebSocketIntegrationTests method setup.

@Before
public void setup() throws Exception {
    this.client = new ReactorNettyWebSocketClient();
    this.server = new ReactorHttpServer();
    this.server.setHandler(createHttpHandler());
    this.server.afterPropertiesSet();
    this.server.start();
    // Set dynamically chosen port
    this.serverPort = this.server.getPort();
    if (this.client instanceof Lifecycle) {
        ((Lifecycle) this.client).start();
    }
    this.gatewayContext = new SpringApplicationBuilder(GatewayConfig.class).properties("ws.server.port:" + this.serverPort, "server.port=0", "spring.jmx.enabled=false").run();
    ConfigurableEnvironment env = this.gatewayContext.getBean(ConfigurableEnvironment.class);
    this.gatewayPort = new Integer(env.getProperty("local.server.port"));
}
Also used : ReactorHttpServer(org.springframework.cloud.gateway.test.support.ReactorHttpServer) ConfigurableEnvironment(org.springframework.core.env.ConfigurableEnvironment) Lifecycle(org.springframework.context.Lifecycle) ReactorNettyWebSocketClient(org.springframework.web.reactive.socket.client.ReactorNettyWebSocketClient) SpringApplicationBuilder(org.springframework.boot.builder.SpringApplicationBuilder) Before(org.junit.Before)

Example 2 with ReactorHttpServer

use of org.springframework.cloud.gateway.test.support.ReactorHttpServer in project spring-cloud-gateway by spring-cloud.

the class SseIntegrationTests method setup.

@Before
public void setup() throws Exception {
    this.server = new ReactorHttpServer();
    this.server.setHandler(createHttpHandler());
    this.server.afterPropertiesSet();
    this.server.start();
    // Set dynamically chosen port
    this.serverPort = this.server.getPort();
    logger.info("SSE Port: " + this.serverPort);
    this.gatewayContext = new SpringApplicationBuilder(GatewayConfig.class).properties("sse.server.port:" + this.serverPort, "server.port=0", "spring.jmx.enabled=false").run();
    ConfigurableEnvironment env = this.gatewayContext.getBean(ConfigurableEnvironment.class);
    this.gatewayPort = new Integer(env.getProperty("local.server.port"));
    this.webClient = WebClient.create("http://localhost:" + this.gatewayPort + "/sse");
    logger.info("Gateway Port: " + this.gatewayPort);
}
Also used : ReactorHttpServer(org.springframework.cloud.gateway.test.support.ReactorHttpServer) ConfigurableEnvironment(org.springframework.core.env.ConfigurableEnvironment) SpringApplicationBuilder(org.springframework.boot.builder.SpringApplicationBuilder) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)2 SpringApplicationBuilder (org.springframework.boot.builder.SpringApplicationBuilder)2 ReactorHttpServer (org.springframework.cloud.gateway.test.support.ReactorHttpServer)2 ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)2 Lifecycle (org.springframework.context.Lifecycle)1 ReactorNettyWebSocketClient (org.springframework.web.reactive.socket.client.ReactorNettyWebSocketClient)1