use of org.springframework.http.server.reactive.bootstrap.ReactorHttpServer in project spring-framework by spring-projects.
the class HttpServerTests method setUp.
@Before
public void setUp() throws Exception {
HttpHandler httpHandler = RouterFunctions.toHttpHandler(route(GET("/test"), request -> ServerResponse.ok().body(Mono.just("It works!"), String.class)));
this.server = new ReactorHttpServer();
this.server.setHandler(httpHandler);
this.server.afterPropertiesSet();
this.server.start();
this.client = WebTestClient.bindToServer().baseUrl("http://localhost:" + this.server.getPort()).build();
}
use of org.springframework.http.server.reactive.bootstrap.ReactorHttpServer in project spring-framework by spring-projects.
the class ZeroCopyIntegrationTests method zeroCopy.
@Test
public void zeroCopy() throws Exception {
// Zero-copy only does not support servlet
assumeTrue(server instanceof ReactorHttpServer || server instanceof UndertowHttpServer);
RestTemplate restTemplate = new RestTemplate();
RequestEntity<?> request = RequestEntity.get(new URI("http://localhost:" + port)).build();
ResponseEntity<byte[]> response = restTemplate.exchange(request, byte[].class);
Resource logo = new ClassPathResource("spring.png", ZeroCopyIntegrationTests.class);
assertTrue(response.hasBody());
assertEquals(logo.contentLength(), response.getHeaders().getContentLength());
assertEquals(logo.contentLength(), response.getBody().length);
assertEquals(MediaType.IMAGE_PNG, response.getHeaders().getContentType());
}
use of org.springframework.http.server.reactive.bootstrap.ReactorHttpServer in project spring-framework by spring-projects.
the class ContextPathIntegrationTests method setup.
@Before
public void setup() throws Exception {
AnnotationConfigApplicationContext context1 = new AnnotationConfigApplicationContext();
context1.register(WebApp1Config.class);
context1.refresh();
AnnotationConfigApplicationContext context2 = new AnnotationConfigApplicationContext();
context2.register(WebApp2Config.class);
context2.refresh();
HttpHandler webApp1Handler = DispatcherHandler.toHttpHandler(context1);
HttpHandler webApp2Handler = DispatcherHandler.toHttpHandler(context2);
this.server = new ReactorHttpServer();
this.server.registerHttpHandler("/webApp1", webApp1Handler);
this.server.registerHttpHandler("/webApp2", webApp2Handler);
this.server.afterPropertiesSet();
this.server.start();
}
use of org.springframework.http.server.reactive.bootstrap.ReactorHttpServer in project spring-framework by spring-projects.
the class ErrorHandlerIntegrationTests method returnValue.
@Test
public void returnValue() throws Exception {
// TODO: fix Reactor
assumeFalse(server instanceof ReactorHttpServer);
RestTemplate restTemplate = new RestTemplate();
restTemplate.setErrorHandler(NO_OP_ERROR_HANDLER);
ResponseEntity<String> response = restTemplate.getForEntity(new URI("http://localhost:" + port + "/returnValue"), String.class);
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode());
}
use of org.springframework.http.server.reactive.bootstrap.ReactorHttpServer in project spring-framework by spring-projects.
the class ErrorHandlerIntegrationTests method response.
@Test
public void response() throws Exception {
// TODO: fix Reactor
assumeFalse(server instanceof ReactorHttpServer);
RestTemplate restTemplate = new RestTemplate();
restTemplate.setErrorHandler(NO_OP_ERROR_HANDLER);
ResponseEntity<String> response = restTemplate.getForEntity(new URI("http://localhost:" + port + "/response"), String.class);
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode());
}
Aggregations