|
|
|
|
@ -1,5 +1,5 @@
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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<>(); |
|
|
|
|
|