replace deprecated method to make code more clean (#2134)
* replace @Deprecated method
This commit is contained in:
@@ -216,7 +216,7 @@ public class NettyRoutingFilter implements GlobalFilter, Ordered {
|
||||
response = ((ServerHttpResponseDecorator) response).getDelegate();
|
||||
}
|
||||
if (response instanceof AbstractServerHttpResponse) {
|
||||
((AbstractServerHttpResponse) response).setStatusCodeValue(clientResponse.status().code());
|
||||
((AbstractServerHttpResponse) response).setRawStatusCode(clientResponse.status().code());
|
||||
}
|
||||
else {
|
||||
// TODO: log warning here, not throw error?
|
||||
|
||||
@@ -105,7 +105,7 @@ public class WebClientHttpRoutingFilter implements GlobalFilter, Ordered {
|
||||
headersSpec = bodySpec;
|
||||
}
|
||||
|
||||
return headersSpec.exchange()
|
||||
return headersSpec.exchangeToMono(Mono::just)
|
||||
// .log("webClient route")
|
||||
.flatMap(res -> {
|
||||
ServerHttpResponse response = exchange.getResponse();
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.unit.DataSize;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
@@ -69,7 +69,7 @@ public class RequestSizeGatewayFilterFactory
|
||||
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
||||
ServerHttpRequest request = exchange.getRequest();
|
||||
String contentLength = request.getHeaders().getFirst("content-length");
|
||||
if (!StringUtils.isEmpty(contentLength)) {
|
||||
if (!ObjectUtils.isEmpty(contentLength)) {
|
||||
Long currentRequestSize = Long.valueOf(contentLength);
|
||||
if (currentRequestSize > requestSizeConfig.getMaxSize().toBytes()) {
|
||||
exchange.getResponse().setStatusCode(HttpStatus.PAYLOAD_TOO_LARGE);
|
||||
|
||||
@@ -24,12 +24,12 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_ORIGINAL_REQUEST_URL_ATTR;
|
||||
import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR;
|
||||
import static org.springframework.util.StringUtils.isEmpty;
|
||||
|
||||
@ConfigurationProperties("spring.cloud.gateway.x-forwarded")
|
||||
public class XForwardedHeadersFilter implements HttpHeadersFilter, Ordered {
|
||||
@@ -270,7 +270,7 @@ public class XForwardedHeadersFilter implements HttpHeadersFilter, Ordered {
|
||||
}
|
||||
|
||||
private static String substringBeforeLast(String str, String separator) {
|
||||
if (isEmpty(str) || isEmpty(separator)) {
|
||||
if (ObjectUtils.isEmpty(str) || ObjectUtils.isEmpty(separator)) {
|
||||
return str;
|
||||
}
|
||||
int pos = str.lastIndexOf(separator);
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.function.Predicate;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
@@ -53,7 +53,7 @@ public class HeaderRoutePredicateFactory extends AbstractRoutePredicateFactory<H
|
||||
|
||||
@Override
|
||||
public Predicate<ServerWebExchange> apply(Config config) {
|
||||
boolean hasRegex = !StringUtils.isEmpty(config.regexp);
|
||||
boolean hasRegex = !ObjectUtils.isEmpty(config.regexp);
|
||||
|
||||
return new GatewayPredicate() {
|
||||
@Override
|
||||
|
||||
@@ -23,7 +23,7 @@ import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.cloud.gateway.support.NotFoundException;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import static java.util.Collections.synchronizedMap;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class InMemoryRouteDefinitionRepository implements RouteDefinitionReposit
|
||||
@Override
|
||||
public Mono<Void> save(Mono<RouteDefinition> route) {
|
||||
return route.flatMap(r -> {
|
||||
if (StringUtils.isEmpty(r.getId())) {
|
||||
if (ObjectUtils.isEmpty(r.getId())) {
|
||||
return Mono.error(new IllegalArgumentException("id may not be empty"));
|
||||
}
|
||||
routes.put(r.getId(), r);
|
||||
|
||||
@@ -39,7 +39,7 @@ public class GatewayHttpTagsProvider implements GatewayTagsProvider {
|
||||
// it needs to be checked for first, otherwise the delegate response
|
||||
// who's status DIDN'T change, will be used
|
||||
if (exchange.getResponse() instanceof AbstractServerHttpResponse) {
|
||||
Integer statusInt = ((AbstractServerHttpResponse) exchange.getResponse()).getStatusCodeValue();
|
||||
Integer statusInt = ((AbstractServerHttpResponse) exchange.getResponse()).getRawStatusCode();
|
||||
if (statusInt != null) {
|
||||
status = String.valueOf(statusInt);
|
||||
httpStatusCodeStr = status;
|
||||
|
||||
@@ -123,11 +123,11 @@ public class GatewayAutoConfigurationTests {
|
||||
assertThat(context).hasSingleBean(ReactorNettyRequestUpgradeStrategy.class);
|
||||
ReactorNettyRequestUpgradeStrategy upgradeStrategy = context
|
||||
.getBean(ReactorNettyRequestUpgradeStrategy.class);
|
||||
assertThat(upgradeStrategy.getMaxFramePayloadLength()).isEqualTo(1024);
|
||||
assertThat(upgradeStrategy.getHandlePing()).isTrue();
|
||||
assertThat(upgradeStrategy.getWebsocketServerSpec().maxFramePayloadLength()).isEqualTo(1024);
|
||||
assertThat(upgradeStrategy.getWebsocketServerSpec().handlePing()).isTrue();
|
||||
assertThat(context).hasSingleBean(ReactorNettyWebSocketClient.class);
|
||||
ReactorNettyWebSocketClient webSocketClient = context.getBean(ReactorNettyWebSocketClient.class);
|
||||
assertThat(webSocketClient.getMaxFramePayloadLength()).isEqualTo(1024);
|
||||
assertThat(webSocketClient.getWebsocketClientSpec().maxFramePayloadLength()).isEqualTo(1024);
|
||||
HttpClientCustomizedConfig config = context.getBean(HttpClientCustomizedConfig.class);
|
||||
assertThat(config.called.get()).isTrue();
|
||||
});
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.reactive.function.client.ClientResponse;
|
||||
@@ -45,7 +46,8 @@ public class CorsTests extends BaseWebClientTests {
|
||||
@Test
|
||||
public void testPreFlightCorsRequest() {
|
||||
ClientResponse clientResponse = webClient.options().uri("/abc/123/function").header("Origin", "domain.com")
|
||||
.header("Access-Control-Request-Method", "GET").exchange().block();
|
||||
.header("Access-Control-Request-Method", "GET")
|
||||
.exchangeToMono(Mono::just).block();
|
||||
HttpHeaders asHttpHeaders = clientResponse.headers().asHttpHeaders();
|
||||
Mono<String> bodyToMono = clientResponse.bodyToMono(String.class);
|
||||
// pre-flight request shouldn't return the response body
|
||||
@@ -60,14 +62,16 @@ public class CorsTests extends BaseWebClientTests {
|
||||
|
||||
@Test
|
||||
public void testCorsRequest() {
|
||||
ClientResponse clientResponse = webClient.get().uri("/abc/123/function").header("Origin", "domain.com")
|
||||
.header(HttpHeaders.HOST, "www.path.org").exchange().block();
|
||||
HttpHeaders asHttpHeaders = clientResponse.headers().asHttpHeaders();
|
||||
Mono<String> bodyToMono = clientResponse.bodyToMono(String.class);
|
||||
assertThat(bodyToMono.block()).isNotNull();
|
||||
assertThat(asHttpHeaders.getAccessControlAllowOrigin())
|
||||
ResponseEntity<String> response = webClient.get().uri("/abc/123/function").header("Origin", "domain.com")
|
||||
.header(HttpHeaders.HOST, "www.path.org")
|
||||
.retrieve()
|
||||
.toEntity(String.class)
|
||||
.block();
|
||||
assertThat(response).isNotNull();
|
||||
assertThat(response.getBody()).isNotNull();
|
||||
assertThat(response.getHeaders().getAccessControlAllowOrigin())
|
||||
.as("Missing header value in response: " + HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN).isEqualTo("*");
|
||||
assertThat(clientResponse.statusCode()).as("CORS request failed.").isEqualTo(HttpStatus.OK);
|
||||
assertThat(response.getStatusCode()).as("CORS request failed.").isEqualTo(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration
|
||||
|
||||
@@ -43,7 +43,6 @@ import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
import static org.springframework.web.reactive.function.BodyExtractors.toMono;
|
||||
|
||||
/**
|
||||
* @author Greg Turnquist
|
||||
@@ -62,7 +61,7 @@ public class SaveSessionGatewayFilterFactoryTests extends BaseWebClientTests {
|
||||
when(mockWebSession.getAttributes()).thenReturn(new HashMap<>());
|
||||
when(mockWebSession.save()).thenReturn(Mono.empty());
|
||||
|
||||
Mono<Map> result = webClient.get().uri("/get").exchange().flatMap(response -> response.body(toMono(Map.class)));
|
||||
Mono<Map> result = webClient.get().uri("/get").retrieve().bodyToMono(Map.class);
|
||||
|
||||
StepVerifier.create(result).consumeNextWith(response -> {
|
||||
// Don't care about data, just need to catch signal
|
||||
|
||||
@@ -52,7 +52,7 @@ public class SecureHeadersGatewayFilterFactoryTests extends BaseWebClientTests {
|
||||
@Test
|
||||
public void secureHeadersFilterWorks() {
|
||||
Mono<ClientResponse> result = webClient.get().uri("/headers").header("Host", "www.secureheaders.org")
|
||||
.exchange();
|
||||
.exchangeToMono(Mono::just);
|
||||
|
||||
SecureHeadersProperties defaults = new SecureHeadersProperties();
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class NonStandardHeadersInResponseTests extends BaseWebClientTests {
|
||||
public void nonStandardHeadersInResponse() {
|
||||
URI uri = UriComponentsBuilder.fromUriString(this.baseUri + "/get-image").build(true).toUri();
|
||||
|
||||
String contentType = WebClient.builder().baseUrl(baseUri).build().get().uri(uri).exchange()
|
||||
String contentType = WebClient.builder().baseUrl(baseUri).build().get().uri(uri).exchangeToMono(Mono::just)
|
||||
.map(clientResponse -> clientResponse.headers().asHttpHeaders().getFirst(HttpHeaders.CONTENT_TYPE))
|
||||
.block();
|
||||
|
||||
|
||||
@@ -94,14 +94,14 @@ public class PathRoutePredicateFactoryTests extends BaseWebClientTests {
|
||||
@Test
|
||||
public void matchOptionalTrailingSeparatorCopiedToMatchTrailingSlash() {
|
||||
Config config = new Config().setPatterns(Arrays.asList("patternA", "patternB"))
|
||||
.setMatchOptionalTrailingSeparator(false);
|
||||
.setMatchTrailingSlash(false);
|
||||
assertThat(config.isMatchTrailingSlash()).isEqualTo(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toStringFormat() {
|
||||
Config config = new Config().setPatterns(Arrays.asList("patternA", "patternB"))
|
||||
.setMatchOptionalTrailingSeparator(false);
|
||||
.setMatchTrailingSlash(false);
|
||||
Predicate predicate = new PathRoutePredicateFactory().apply(config);
|
||||
assertThat(predicate.toString()).contains("patternA").contains("patternB").contains("false");
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class RemoteAddrRoutePredicateFactoryTests extends BaseWebClientTests {
|
||||
|
||||
@Test
|
||||
public void remoteAddrWorks() {
|
||||
Mono<ClientResponse> result = webClient.get().uri("/ok/httpbin/").exchange();
|
||||
Mono<ClientResponse> result = webClient.get().uri("/ok/httpbin/").exchangeToMono(Mono::just);
|
||||
|
||||
StepVerifier.create(result).consumeNextWith(response -> assertStatus(response, HttpStatus.OK)).expectComplete()
|
||||
.verify(DURATION);
|
||||
@@ -61,7 +61,7 @@ public class RemoteAddrRoutePredicateFactoryTests extends BaseWebClientTests {
|
||||
|
||||
@Test
|
||||
public void remoteAddrRejects() {
|
||||
Mono<ClientResponse> result = webClient.get().uri("/nok/httpbin/").exchange();
|
||||
Mono<ClientResponse> result = webClient.get().uri("/nok/httpbin/").exchangeToMono(Mono::just);
|
||||
|
||||
StepVerifier.create(result).consumeNextWith(response -> assertStatus(response, HttpStatus.NOT_FOUND))
|
||||
.expectComplete().verify(DURATION);
|
||||
@@ -70,7 +70,7 @@ public class RemoteAddrRoutePredicateFactoryTests extends BaseWebClientTests {
|
||||
@Test
|
||||
public void remoteAddrWorksWithXForwardedRemoteAddress() {
|
||||
Mono<ClientResponse> result = webClient.get().uri("/xforwardfor").header("X-Forwarded-For", "12.34.56.78")
|
||||
.exchange();
|
||||
.exchangeToMono(Mono::just);
|
||||
|
||||
StepVerifier.create(result).consumeNextWith(response -> assertStatus(response, HttpStatus.OK)).expectComplete()
|
||||
.verify(Duration.ofSeconds(20));
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.springframework.cloud.gateway.handler.predicate.HostRoutePredicateFac
|
||||
import org.springframework.cloud.gateway.handler.predicate.PredicateDefinition;
|
||||
import org.springframework.cloud.gateway.handler.predicate.RoutePredicateFactory;
|
||||
import org.springframework.cloud.gateway.support.ConfigurationService;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -129,7 +129,7 @@ public class RouteDefinitionRouteLocatorTests {
|
||||
}
|
||||
else {
|
||||
String simpleName = target.getClass().getSimpleName();
|
||||
if (StringUtils.isEmpty(simpleName)) {
|
||||
if (ObjectUtils.isEmpty(simpleName)) {
|
||||
// maybe a lambda using new toString methods
|
||||
simpleName = target.toString();
|
||||
}
|
||||
|
||||
@@ -21,9 +21,8 @@ import java.util.Map;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.springframework.boot.context.properties.bind.BindException;
|
||||
import org.springframework.boot.context.properties.bind.Bindable;
|
||||
@@ -35,16 +34,11 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class ConfigurationServiceTests {
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void validationOnCreateWorks() {
|
||||
thrown.expect(BindException.class);
|
||||
|
||||
Map<String, Object> map = Collections.singletonMap("config.value", 11);
|
||||
|
||||
ConfigurationService.bindOrCreate(Bindable.of(ValidatedConfig.class), map, "config", getValidator(), null);
|
||||
Assert.assertThrows(BindException.class, () -> ConfigurationService.bindOrCreate(Bindable.of(ValidatedConfig.class), map, "config", getValidator(), null));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -59,12 +53,12 @@ public class ConfigurationServiceTests {
|
||||
|
||||
@Test
|
||||
public void validationOnBindWorks() {
|
||||
thrown.expect(BindException.class);
|
||||
|
||||
Map<String, Object> map = Collections.singletonMap("config.value", 11);
|
||||
|
||||
ValidatedConfig config = new ValidatedConfig();
|
||||
ConfigurationService.bindOrCreate(Bindable.ofInstance(config), map, "config", getValidator(), null);
|
||||
|
||||
Assert.assertThrows(BindException.class, () -> ConfigurationService.bindOrCreate(Bindable.ofInstance(config), map, "config", getValidator(), null));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -20,9 +20,8 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
|
||||
import org.springframework.mock.web.server.MockServerWebExchange;
|
||||
@@ -32,9 +31,6 @@ import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.e
|
||||
|
||||
public class ServerWebExchangeUtilsTests {
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void expandWorks() {
|
||||
HashMap<String, String> vars = new HashMap<>();
|
||||
@@ -53,8 +49,7 @@ public class ServerWebExchangeUtilsTests {
|
||||
@Test
|
||||
public void missingVarThrowsException() {
|
||||
MockServerWebExchange exchange = mockExchange(Collections.emptyMap());
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
expand(exchange, "my-{foo}-{baz}");
|
||||
Assert.assertThrows(IllegalArgumentException.class, () -> expand(exchange, "my-{foo}-{baz}"));
|
||||
}
|
||||
|
||||
private MockServerWebExchange mockExchange(Map<String, String> vars) {
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
import static org.springframework.web.reactive.function.BodyExtractors.toMono;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT)
|
||||
@@ -44,7 +43,7 @@ public class PostTests extends BaseWebClientTests {
|
||||
@Test
|
||||
public void postWorks() {
|
||||
Mono<Map> result = webClient.post().uri("/post").header("Host", "www.example.org").bodyValue("testdata")
|
||||
.exchange().flatMap(response -> response.body(toMono(Map.class)));
|
||||
.retrieve().bodyToMono(Map.class);
|
||||
|
||||
StepVerifier.create(result).consumeNextWith(map -> assertThat(map).containsEntry("data", "testdata"))
|
||||
.expectComplete().verify(DURATION);
|
||||
|
||||
@@ -54,7 +54,6 @@ import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.core.ResolvableType.forClassWithGenerics;
|
||||
import static org.springframework.http.MediaType.TEXT_EVENT_STREAM;
|
||||
import static org.springframework.web.reactive.function.BodyExtractors.toFlux;
|
||||
|
||||
/**
|
||||
* @author Sebastien Deleuze
|
||||
@@ -124,16 +123,16 @@ public class SseIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void sseAsString() {
|
||||
Flux<String> result = this.webClient.get().uri("/string").accept(TEXT_EVENT_STREAM).exchange()
|
||||
.flatMapMany(response -> response.bodyToFlux(String.class));
|
||||
Flux<String> result = this.webClient.get().uri("/string").accept(TEXT_EVENT_STREAM)
|
||||
.retrieve().bodyToFlux(String.class);
|
||||
|
||||
StepVerifier.create(result).expectNext("foo 0").expectNext("foo 1").thenCancel().verify(Duration.ofSeconds(5L));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sseAsPerson() {
|
||||
Flux<Person> result = this.webClient.get().uri("/person").accept(TEXT_EVENT_STREAM).exchange()
|
||||
.flatMapMany(response -> response.bodyToFlux(Person.class));
|
||||
Flux<Person> result = this.webClient.get().uri("/person").accept(TEXT_EVENT_STREAM)
|
||||
.retrieve().bodyToFlux(Person.class);
|
||||
|
||||
StepVerifier.create(result).expectNext(new Person("foo 0")).expectNext(new Person("foo 1")).thenCancel()
|
||||
.verify(Duration.ofSeconds(5L));
|
||||
@@ -143,10 +142,8 @@ public class SseIntegrationTests {
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void sseAsEvent() {
|
||||
ResolvableType type = forClassWithGenerics(ServerSentEvent.class, String.class);
|
||||
Flux<ServerSentEvent<String>> result = this.webClient.get().uri("/event").accept(TEXT_EVENT_STREAM).exchange()
|
||||
.flatMapMany(
|
||||
response -> response.body(toFlux(new ParameterizedTypeReference<ServerSentEvent<String>>() {
|
||||
})));
|
||||
Flux<ServerSentEvent<String>> result = this.webClient.get().uri("/event").accept(TEXT_EVENT_STREAM)
|
||||
.retrieve().bodyToFlux(new ParameterizedTypeReference<ServerSentEvent<String>>() { });
|
||||
|
||||
StepVerifier.create(result).consumeNextWith(event -> {
|
||||
assertThat(event.id()).isEqualTo("0");
|
||||
@@ -166,10 +163,8 @@ public class SseIntegrationTests {
|
||||
@Test
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void sseAsEventWithoutAcceptHeader() {
|
||||
Flux<ServerSentEvent<String>> result = this.webClient.get().uri("/event").accept(TEXT_EVENT_STREAM).exchange()
|
||||
.flatMapMany(
|
||||
response -> response.body(toFlux(new ParameterizedTypeReference<ServerSentEvent<String>>() {
|
||||
})));
|
||||
Flux<ServerSentEvent<String>> result = this.webClient.get().uri("/event").accept(TEXT_EVENT_STREAM)
|
||||
.retrieve().bodyToFlux(new ParameterizedTypeReference<ServerSentEvent<String>>() { });
|
||||
|
||||
StepVerifier.create(result).consumeNextWith(event -> {
|
||||
assertThat(event.id()).isEqualTo("0");
|
||||
|
||||
@@ -37,7 +37,9 @@ public class ReactorHttpServer extends AbstractHttpServer {
|
||||
protected void initServer() {
|
||||
this.reactorHandler = createHttpHandlerAdapter();
|
||||
this.reactorServer = reactor.netty.http.server.HttpServer.create()
|
||||
.tcpConfiguration(server -> server.host(getHost())).port(getPort());
|
||||
.host(getHost())
|
||||
.port(getPort());
|
||||
|
||||
}
|
||||
|
||||
private ReactorHttpHandlerAdapter createHttpHandlerAdapter() {
|
||||
|
||||
Reference in New Issue
Block a user