Deprecated ClientRequest.method in favor of ClientRequest.create
The former method clashed with the ClientRequest.method() getter.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -50,7 +50,7 @@ public class DefaultClientRequestBuilderTests {
|
||||
|
||||
@Test
|
||||
public void from() throws Exception {
|
||||
ClientRequest other = ClientRequest.method(GET, URI.create("http://example.com"))
|
||||
ClientRequest other = ClientRequest.create(GET, URI.create("http://example.com"))
|
||||
.header("foo", "bar")
|
||||
.cookie("baz", "qux").build();
|
||||
ClientRequest result = ClientRequest.from(other)
|
||||
@@ -68,7 +68,7 @@ public class DefaultClientRequestBuilderTests {
|
||||
@Test
|
||||
public void method() throws Exception {
|
||||
URI url = new URI("http://example.com");
|
||||
ClientRequest.Builder builder = ClientRequest.method(DELETE, url);
|
||||
ClientRequest.Builder builder = ClientRequest.create(DELETE, url);
|
||||
assertEquals(DELETE, builder.build().method());
|
||||
|
||||
builder.method(OPTIONS);
|
||||
@@ -79,7 +79,7 @@ public class DefaultClientRequestBuilderTests {
|
||||
public void url() throws Exception {
|
||||
URI url1 = new URI("http://example.com/foo");
|
||||
URI url2 = new URI("http://example.com/bar");
|
||||
ClientRequest.Builder builder = ClientRequest.method(DELETE, url1);
|
||||
ClientRequest.Builder builder = ClientRequest.create(DELETE, url1);
|
||||
assertEquals(url1, builder.build().url());
|
||||
|
||||
builder.url(url2);
|
||||
@@ -87,15 +87,15 @@ public class DefaultClientRequestBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cookie() throws Exception {
|
||||
ClientRequest result = ClientRequest.method(GET, URI.create("http://example.com"))
|
||||
public void cookie() {
|
||||
ClientRequest result = ClientRequest.create(GET, URI.create("http://example.com"))
|
||||
.cookie("foo", "bar").build();
|
||||
assertEquals("bar", result.cookies().getFirst("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void build() throws Exception {
|
||||
ClientRequest result = ClientRequest.method(GET, URI.create("http://example.com"))
|
||||
public void build() {
|
||||
ClientRequest result = ClientRequest.create(GET, URI.create("http://example.com"))
|
||||
.header("MyKey", "MyValue")
|
||||
.cookie("foo", "bar")
|
||||
.build();
|
||||
@@ -111,7 +111,7 @@ public class DefaultClientRequestBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bodyInserter() throws Exception {
|
||||
public void bodyInserter() {
|
||||
String body = "foo";
|
||||
BodyInserter<String, ClientHttpRequest> inserter =
|
||||
(response, strategies) -> {
|
||||
@@ -121,7 +121,7 @@ public class DefaultClientRequestBuilderTests {
|
||||
return response.writeWith(Mono.just(buffer));
|
||||
};
|
||||
|
||||
ClientRequest result = ClientRequest.method(POST, URI.create("http://example.com"))
|
||||
ClientRequest result = ClientRequest.create(POST, URI.create("http://example.com"))
|
||||
.body(inserter).build();
|
||||
|
||||
List<HttpMessageWriter<?>> messageWriters = new ArrayList<>();
|
||||
@@ -140,10 +140,10 @@ public class DefaultClientRequestBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bodyClass() throws Exception {
|
||||
public void bodyClass() {
|
||||
String body = "foo";
|
||||
Publisher<String> publisher = Mono.just(body);
|
||||
ClientRequest result = ClientRequest.method(POST, URI.create("http://example.com"))
|
||||
ClientRequest result = ClientRequest.create(POST, URI.create("http://example.com"))
|
||||
.body(publisher, String.class).build();
|
||||
|
||||
List<HttpMessageWriter<?>> messageWriters = new ArrayList<>();
|
||||
@@ -162,11 +162,11 @@ public class DefaultClientRequestBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bodyParameterizedTypeReference() throws Exception {
|
||||
public void bodyParameterizedTypeReference() {
|
||||
String body = "foo";
|
||||
Publisher<String> publisher = Mono.just(body);
|
||||
ParameterizedTypeReference<String> typeReference = new ParameterizedTypeReference<String>() {};
|
||||
ClientRequest result = ClientRequest.method(POST, URI.create("http://example.com"))
|
||||
ClientRequest result = ClientRequest.create(POST, URI.create("http://example.com"))
|
||||
.body(publisher, typeReference).build();
|
||||
|
||||
List<HttpMessageWriter<?>> messageWriters = new ArrayList<>();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,8 +36,8 @@ import static org.springframework.web.reactive.function.client.ExchangeFilterFun
|
||||
public class ExchangeFilterFunctionsTests {
|
||||
|
||||
@Test
|
||||
public void andThen() throws Exception {
|
||||
ClientRequest request = ClientRequest.method(GET, URI.create("http://example.com")).build();
|
||||
public void andThen() {
|
||||
ClientRequest request = ClientRequest.create(GET, URI.create("http://example.com")).build();
|
||||
ClientResponse response = mock(ClientResponse.class);
|
||||
ExchangeFunction exchange = r -> Mono.just(response);
|
||||
|
||||
@@ -66,8 +66,8 @@ public class ExchangeFilterFunctionsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void apply() throws Exception {
|
||||
ClientRequest request = ClientRequest.method(GET, URI.create("http://example.com")).build();
|
||||
public void apply() {
|
||||
ClientRequest request = ClientRequest.create(GET, URI.create("http://example.com")).build();
|
||||
ClientResponse response = mock(ClientResponse.class);
|
||||
ExchangeFunction exchange = r -> Mono.just(response);
|
||||
|
||||
@@ -85,8 +85,8 @@ public class ExchangeFilterFunctionsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void basicAuthenticationUsernamePassword() throws Exception {
|
||||
ClientRequest request = ClientRequest.method(GET, URI.create("http://example.com")).build();
|
||||
public void basicAuthenticationUsernamePassword() {
|
||||
ClientRequest request = ClientRequest.create(GET, URI.create("http://example.com")).build();
|
||||
ClientResponse response = mock(ClientResponse.class);
|
||||
|
||||
ExchangeFunction exchange = r -> {
|
||||
@@ -102,14 +102,14 @@ public class ExchangeFilterFunctionsTests {
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void basicAuthenticationInvalidCharacters() throws Exception {
|
||||
public void basicAuthenticationInvalidCharacters() {
|
||||
|
||||
ExchangeFilterFunctions.basicAuthentication("foo", "\ud83d\udca9");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void basicAuthenticationAttributes() throws Exception {
|
||||
ClientRequest request = ClientRequest.method(GET, URI.create("http://example.com"))
|
||||
public void basicAuthenticationAttributes() {
|
||||
ClientRequest request = ClientRequest.create(GET, URI.create("http://example.com"))
|
||||
.attributes(basicAuthenticationCredentials("foo", "bar"))
|
||||
.build();
|
||||
ClientResponse response = mock(ClientResponse.class);
|
||||
@@ -127,8 +127,8 @@ public class ExchangeFilterFunctionsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void basicAuthenticationAbsentAttributes() throws Exception {
|
||||
ClientRequest request = ClientRequest.method(GET, URI.create("http://example.com")).build();
|
||||
public void basicAuthenticationAbsentAttributes() {
|
||||
ClientRequest request = ClientRequest.create(GET, URI.create("http://example.com")).build();
|
||||
ClientResponse response = mock(ClientResponse.class);
|
||||
|
||||
ExchangeFunction exchange = r -> {
|
||||
@@ -143,8 +143,8 @@ public class ExchangeFilterFunctionsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void statusHandlerMatch() throws Exception {
|
||||
ClientRequest request = ClientRequest.method(GET, URI.create("http://example.com")).build();
|
||||
public void statusHandlerMatch() {
|
||||
ClientRequest request = ClientRequest.create(GET, URI.create("http://example.com")).build();
|
||||
ClientResponse response = mock(ClientResponse.class);
|
||||
when(response.statusCode()).thenReturn(HttpStatus.NOT_FOUND);
|
||||
|
||||
@@ -161,8 +161,8 @@ public class ExchangeFilterFunctionsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void statusHandlerNoMatch() throws Exception {
|
||||
ClientRequest request = ClientRequest.method(GET, URI.create("http://example.com")).build();
|
||||
public void statusHandlerNoMatch() {
|
||||
ClientRequest request = ClientRequest.create(GET, URI.create("http://example.com")).build();
|
||||
ClientResponse response = mock(ClientResponse.class);
|
||||
when(response.statusCode()).thenReturn(HttpStatus.NOT_FOUND);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user